"M. Edward (Ed) Borasky" <znmeb / cesmail.net> writes:

>> 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. :(

You're telling me I shouldn't be using %MEM.  I already knew that, and
that was why I was making this post.  I'm basing my conclusions off VSZ.

VSZ is the total amount of virtual memory allocated by the OS to the
application, and is also the number that Linux uses when deciding what
to kill.  Since this began with Mongrel processes being killed, this
is the relevant number.  As ruby threads aren't seen as threads by the
underlying OS, what you see with java (where the OS does see the java
threads) really isn't relevant.  As far as the OS is concerned, ruby
is just one process like other processes - ruby threads don't, for
example, take advantage of SMP machines and execute in parallel on
separate CPUs.

-- 
s=%q(  Daniel Martin -- martin / snowplow.org
       puts "s=%q(#{s})",s.map{|i|i}[1]       )
       puts "s=%q(#{s})",s.map{|i|i}[1]