Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSZ vs RSS memory and swap space

Tags:

memory

ps

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

like image 682
ftiaronsem Avatar asked Aug 07 '15 00:08

ftiaronsem


People also ask

What is the difference between VSZ and RSS?

RSS is Resident Set Size (physically resident memory - this is currently occupying space in the machine's physical memory), and VSZ is Virtual Memory Size (address space allocated - this has addresses allocated in the process's memory map, but there isn't necessarily any actual memory behind it all right now).

What is VSZ in memory?

VSZ is short for Virtual Memory Size. It's the total amount of memory a process may hypothetically access. It accounts for the size of the binary itself, any linked libraries, and any stack or heap allocations. When a process is started, VSZ memory becomes RSS memory, over which we'll go now.

What is RSS and VMS in memory?

rss is the Resident Set Size, which is the actual physical memory the process is using. vms is the Virtual Memory Size which is the virtual memory that process is using.

What does RSS mean in PS?

PS service RSS stands for Resident Set Size and shows how much RAM is utilized at the time the command is output. It also should be noted that it shows the entire stack of physically allocated memory. VSZ - Virtual Memory Size.


1 Answers

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.

like image 179
incompetent Avatar answered Nov 16 '22 22:11

incompetent