Path: utzoo!attcan!uunet!cs.utexas.edu!rice!sun-spots-request From: lm@sun.com (Larry McVoy) Newsgroups: comp.sys.sun Subject: Re: Memory Usage Questions Keywords: SunOS Message-ID: <8647@brazos.Rice.edu> Date: 6 Jun 90 21:42:44 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 28 Approved: Sun-Spots@rice.edu X-Refs: Original: v9n196, Replies: v9n200 X-Sun-Spots-Digest: Volume 9, Issue 206, message 1 > 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@sun.com