Mark M. Hoffman on 29 Jan 2004 15:38:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Measuring the memory usage of a process


* Walt Mankowski <waltman@pobox.com> [2004-01-28 14:25:56 -0500]:
> I have a program I'm working on that does number crunching on big
> matrices.  It can run for a long time, and can eat up a lot of
> memory.  This morning I tweaked the code and wanted to see if it's now
> using less memory.
> 
> My first cut at doing this was to run the old and new code and look at
> them with top(1) while they were running.  The old code had VIRT and
> RES on the order of 40 megs, and the new code was around 30 megs.
> 
> Then I wanted to see if I could get a more accurate reading.  I took a
> look at the man page for time(1), and saw that it could report on
> memory usage as well as run time and cpu usage.  But when I run the
> program with time, the fields for memory usage always show up as 0.

<snip>

> Does anyone know why time(1) has so many fields set to 0?  Is there a

The man page says:

	"Not all resources are measured by all versions of Unix,
	so some of  the values  might  be  reported  as zero.  
	The present selection was mostly inspired by the data
	provided by 4.2 or 4.3BSD."

> better utility I could be using to get this information?

Is it a C program?  Try valgrind (if it's not too slow)...

http://valgrind.kde.org/

Or, you could also try to read it out of /proc/<pid>/status.

Regards,

-- 
Mark M. Hoffman
mhoffman@lightlink.com

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug