views:

5325

answers:

3

Can somebody give some clear explanation of the meaning of the SIZE and RSS values we get from prstat in Solaris?

I wrote a testing C++ application that allocates memory with new[], fills it and frees it with delete[].

As I understood, the SIZE value should be related to how much virtual memory has been "reserved" by the process, that is memory "malloced" or "newed".

That memory doesn't sum up in the RSS value unless I really use it (filling with some values). But then even if I free the memory, the RSS doesn't drop.

I don't understand what semantic I can correctly assign to those 2 values.

A: 

Size is the total virtual memory size of the process, including all mapped files and devices, and RSS should be the resident set size, but is completely unreliable, you should try to get that information from pmap.

Saiyine
A: 

As a general rule once memory is allocated to a process it will never be given back to the operating system. On Unix systems the sbrk() call is used to extend the processes address space, and there is not analogous call to go in the other direction.

John Allen
+1  A: 

RSS is (AFAIK reliably) representing how much physical memory a process is using. Using Solaris default memory allocator, freeing memory doesn't do anything about RSS as it just changes some pointers and values to tell that memory is free to be reused. If you don't use again that memory by allocating it again, it will eventually be paginated out and the RSS will drop.

If you want freed memory to be returned immediately after a free, you can use the Solaris mmap allocator like this:

export LD_PRELOAD=libumem.so
export UMEM_OPTIONS=backend=mmap
jlliagre