From: "M. Edward (Ed) Borasky" Date: 2006-08-27T15:44:13+09:00 Subject: Re: [ANN] Mongrel 0.3.13.4 Pre-Release -- Ruby's LEAK Fixed (Death To Mutex!) Daniel Martin wrote: > There's a problem with how this script measures its memory usage - it > measures %MEM, which is proportional to RSS. However, RSS is just how > much of the program's memory is *resident*; i.e. not swapped out. You're assuming here that the OS is accurately counting RSS and that the user-space tool is correctly picking it up from the OS. That's not necessarily a given in Linux. :) What's worse, no two programmers have the same view of how one should export performance counters in /proc, nor is there often much documentation except the source. "vi /usr/src/linux/fs/proc/*.c" is your friend. :) > To look at how much total memory is used, the variable you want is > VSZ, which isn't available in a "ps v" but is in a "ps u". I modified > your script to look at the %MEM, VSZ, and RSS numbers from "ps u" and > also to run GC.start a variable number of times. Yeah, but ... threads share the same virtual address space, making the "%MEM" more or less meaningless. To use the J word again, a Java runtime can have ten or twenty or more threads, all sharing the same address space and all having the same VSZ. They get counted more than once. Ugly. Basically, if you want accurate memory usage information from Linux, you need to read from /dev/kmem and walk the tables yourself. :(