Walt Mankowski on 28 Jan 2004 19:26:03 -0000


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

[PLUG] Measuring the memory usage of a process


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.

Here's a sample run:

% /usr/bin/time -v ./cctl-bin ../data/train_med.txt /dev/null pda 1 0 0 >/dev/null
        Command being timed: "./cctl-bin ../data/train_med.txt /dev/null pda 1 0 0"
        User time (seconds): 46.19
        System time (seconds): 0.21
        Percent of CPU this job got: 82%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:56.24
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 0
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 297
        Minor (reclaiming a frame) page faults: 12248
        Voluntary context switches: 0
        Involuntary context switches: 0
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

Does anyone know why time(1) has so many fields set to 0?  Is there a
better utility I could be using to get this information?

Thanks.

Walt

Attachment: signature.asc
Description: Digital signature