Memory Usage Questions

Larry McVoy lm at sun.com
Thu Jun 7 07:42:44 AEST 1990


> How does one determine the system memory usage, both physical and virtual?
>
> "ps" and "top" both often report a programs size (SZ) as less than the
> resident size (RSS).  This does not seem reasonable.  Further, how does
> the space required for shared libraries get accounted ? Is it charged
> againt each program using the library ? Not accounted at all ?

SZ represents the size of the executable associated with this process.
The executable is the chunk of code that contains main().  It may not
contain much more than that.

A process has a virtual address space, broken into page sized chunks.  In
order to use a page of its address space the process must have a
translation (something that converts from virtual addr to physical addr).
The RSS size represents the number of active translations.  It has little
to do with SZ.

Since shared libraries are mmap-ed into a process' address space, the RSS
gets larger while the SZ stays the same.  This is where we get the
confusing SZ < RSS numbers.

Because of the sharing of libraries, computing the amount of memory in use
by a single process has become difficult.  There are pointers to what it
is using but no back pointers to who else is using the same thing.  So
it's easy to say that "ls" is using 5 pages of libc.  It's hard to figure
out who else might be using those same pages.  

Larry McVoy, Sun Microsystems    (415) 336-7627      ...!sun!lm or lm at sun.com



More information about the Comp.sys.sun mailing list