Meaning of SIZE and RSS values in prstat output


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.

Best Solution

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 UMEM_OPTIONS=backend=mmap
Related Question