get max. memory-usage of a program
am 16.10.2007 10:46:31 von Martin Abraham
hello guys,
i'm looking for a way to get displayed how much memory a program (e.g.
pdflatex) needs maximal while running.
do you guys know any simple way to solve this in the shell?
regards,
Martin
Re: get max. memory-usage of a program
am 16.10.2007 12:12:19 von ramesh.thangamani
On Oct 16, 1:46 pm, Martin Abraham wrote:
> hello guys,
>
> i'm looking for a way to get displayed how much memory a program (e.g.
> pdflatex) needs maximal while running.
>
> do you guys know any simple way to solve this in the shell?
>
> regards,
>
> Martin
Are you using Linux. In linux i could see the command /usr/bin/time is
useful in finding information on how much time the process takes. It
also provides information on memory.
% /usr/bin/time --help
Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--
verbose]
[--portability] [--format=3Dformat] [--output=3Dfile] [--version]
[--help] command [arg...]
The format string
The format is interpreted in the usual printf-like way.
Ordinary char-
acters are directly copied, tab, newline and backslash are
escaped
using \t, \n and \\, a percent sign is represented by %%, and
otherwise
% indicates a conversion. The program time will always add a
trailing
newline itself. The conversions follow. All of those used by
tcsh(1)
are supported.
Time
%E Elapsed real time (in [hours:]minutes:seconds).
%e (Not in tcsh.) Elapsed real time (in seconds).
%S Total number of CPU-seconds that the process spent
in kernel
mode.
%U Total number of CPU-seconds that the process spent in
user mode.
%P Percentage of the CPU that this job got, computed as (%U
+ %S) /
%E.
Memory
%M Maximum resident set size of the process during its
lifetime, in
Kbytes.
%t (Not in tcsh.) Average resident set size of the
process, in
Kbytes.
%K Average total (data+stack+text) memory use of the
process, in
Kbytes.
%D Average size of the process=E2s unshared data area, in
Kbytes.
%p (Not in tcsh.) Average size of the process=E2s
unshared stack
space, in Kbytes.
%X Average size of the process=E2s shared text space, in
Kbytes.
%Z (Not in tcsh.) System=E2s page size, in bytes. This is a
per-sys-
tem constant, but varies between systems.
%F Number of major page faults that occurred while the
process was
running. These are faults where the page has to be read
in from
disk.
%R Number of minor, or recoverable, page faults. These
are faults
for pages that are not valid but which have not yet been
claimed
by other virtual pages. Thus the data in the page
is still
valid but the system tables must be updated.
%W Number of times the process was swapped out of main
memory.
%c Number of times the process was context-switched
involuntarily
(because the time slice expired).
%w Number of waits: times that the program was context-
switched
voluntarily, for instance while waiting for an I/O
operation to
complete.
Re: get max. memory-usage of a program
am 16.10.2007 15:02:04 von Martin Abraham
Hi ramesh (?!)
> ramesh.thangamani@gmail.com wrote:
> [..]
> Are you using Linux.
Yes, i do.
> [..]
> In linux i could see the command /usr/bin/time is
> useful in finding information on how much time the process takes. It
> also provides information on memory.
> [..]
It seems to me it's a great small tool for timing, but for memory-usage it
does not work for me. Here is my output of "time --verbose ".
I don't see any usefull information about memory-usage.
Am i doing something wrong?
Regards,
Martin
Systen: Ubuntu Feisty Faun, KSH, GNU Time 1.7
Command being timed: ""
User time (seconds): 0.35
System time (seconds): 0.03
Percent of CPU this job got: 47%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.82
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: 0
Minor (reclaiming a frame) page faults: 2053
Voluntary context switches: 1
Involuntary context switches: 213
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
Re: get max. memory-usage of a program
am 16.10.2007 23:39:52 von Martin Abraham
Hi guys,
i think valgrind is the tool of my choice.
valgrind --tool=massif
using the massif tool you can profile how much heap the program takes.
regards,
Martin