I am trying to understand the memory usage of a large scale simulation that we are trying to run. When I run it "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 that simulation that each occupy 1.6gb (200 million doubles). Based on the information in
What is RSS and VSZ in Linux memory management
I expected that memory to be listed under RSS, but RSS is only 377MB. Based on the information in the stackoverflow thread I concluded that the memory must be swapped out and looked at "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! Aside from the fact that it is too small anyway. So where is this difference in RSS vs VSZ coming from? Why are the arrays that we allocate part of VSZ and not part of RSS?
I appreciate all help
Simple answer to your question is that arrays are defined in virtual space thats why memory for array is shown in VSZ only when you will use array it wil become part of RSS. in my view by keeping your thinking simple will give you explanation. VSZ is virtual memory which a process can use while RSS is physical memory actually allocated at the moment. When a virtual memory is actually used OS will allocate the memory which will increase the RSS.