[vox-tech] command to monitor memory usage

Ken Bloom kbloom at gmail.com
Sun Aug 23 08:35:18 PDT 2009


On Sun, 2009-08-23 at 01:45 -0400, Peter Jay Salzman wrote:
> On Sat 22 Aug 09, 10:37 PM, Bill Kendrick <nbs at sonic.net> said:
> > On Sat, Aug 22, 2009 at 09:37:49PM -0500, Ken Bloom wrote:
> > > Top is good if you get the filtering and sorting options right so that
> > > the process you're interested in stays on the list (and doesn't get
> > > crowded out of the list by more resource-hungry programs).
> > <snip>
> > 
> > Not that I've ever really done it, but it's probably also reasonable
> > to go into /proc/{PROCESS_ID}/ and do a 'cat status' and/or some other
> > 'file(s).'  No?
> > 
> > -bill!
> 
> Prolly not.  Which fields relate to memory usage?  I took a look; can't
> figure it out.  Proc files aren't terribly concerned with human readability;
> they are more meant for tools.
> 
> Why not just use ps?  It's there, it works, it's reasonably friendly, it has
> a man page.  :)

The fields in /proc/$pid/status that start with Vm (e.g. VmExe, VmStk,
VmRss) the sizes of various different pieces of memory. /proc/$pid/maps
tells you the addresses taken up by mmapped files (such as libraries) as
well as the size of the stack and the heap. Some quick hexidecimal
subtraction can tell you how big these spaces are.

AFAIK, because Linux has lots of great ways of sharing physical memory
pages between processes, and only loading the parts of libraries that it
needs, nothing can tell you how much physical memory space is occupied
by a given program.

--Ken


More information about the vox-tech mailing list