VSZ vs RSS memory and swap space
I am trying to understand the memory usage of the large scale simulation we are trying to run. When I run "ps" reports
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
myuser 5252 97.7 0.5 5751412 377392 ? Rs 19:49 1:15 myprogram
We have three arrays in this simulation, each taking up 1.6 GB (200 million doubles). Based on information in
What is RSS and VSZ in Linux memory management
I expected memory to be listed under RSS, but RSS is only 377MB. Based on the information on stackoverflow I have come to the conclusion that the memory should be swapped and treated as "free -m"
total used free shared buffers cached
Mem: 64391 5985 58406 0 463 1295
-/+ buffers/cache: 4226 60164
Swap: 4766 0 4766
and swap is not used at all! Except that it's too small anyway. So where is the difference in RSS vs VSZ? Why are the arrays we allocate part of VSZ and not part of RSS?
I appreciate all the help
source to share
The simple answer to your question is that arrays are defined in virtual space, so the memory for the array is only shown in VSZ when you use the array that will become part of the RSS. in my opinion, keeping your thinking simple will give you an explanation. VSZ is the virtual memory that the process can use, and RSS is the physical memory actually allocated at the moment. When virtual memory is actually used, the OS will allocate memory which will increase the RSS value.
source to share