This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

memusage (1) man page


memusage man page.

    options of command in synopsis to lowercase

.\" Copyright (c) 2013, Peter Schiffer (
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" GNU General Public License for more details.
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, see
.\" <>.
.TH MEMUSAGE 1 2013-04-10 "GNU glibc 2.18" "Memory diagnostic tools"
memusage \- profile memory usage of a program
.BR memusage " [\fIoption\fR]... \fIprogram\fR [\fIprogramoption\fR]..."
.B memusage
is a bash script which can profile memory usage of a program. It preloads
library to the user's environment using
environment variable. The
library traces memory allocation by intercepting calls to
.BR malloc (3),
.BR free (3),
.BR realloc (3)
and various other calls.
.B memusage
can output text representation of the collected data, or it can use
.BR memusagestat (1)
utility (see
.B -p
to create a PNG file containing graphical representation
of the collected data.
List of monitored functions:
.BI "void *malloc(size_t " "size" );
.BI "void *calloc(size_t " "nmemb" ", size_t " "size" );
.BI "void *realloc(void " "*ptr" ", size_t "  "size" );
.BI "void *mmap(void " "*addr" ", size_t " "length" ", int " "prot",
.BI "int " "flags" ", int " "fd" ", off_t " "offset");
.BI "void *mremap(void " "*old_address" ", size_t " "old_size",
.BI "size_t " "new_size" ", int " "flags",
.BI "... /* void " "*new_address" " */);"
Description of a memory usage summary:
\fBheap total\fR:
Sum of \fIsize\fR arguments of all malloc calls,
sum of all product of arguments (\fInmemb\fR*\fIsize\fR) of calloc call
and sum of \fIlength\fR arguments of mmap calls.
In a case of realloc, respectively mremap, if a new size of an original malloc,
respectively mremap call is bigger than an old one,
sum of all such differences (new size - old size) is added.
\fBheap peak\fR:
Maximum of all \fIsize\fR arguments of malloc,
all products of \fInmemb\fR*\fIsize\fR of calloc,
all \fIsize\fR arguments of realloc, \fIlength\fR arguments of mmap and
\fInew_size\fR arguments of mremap.
\fBstack peak\fR:
Before the first call to any monitored function,
stack pointer address (base stack pointer) is saved.
After each function call, actual stack pointer address is read and
the difference between the base stack pointer computed.
Maximum of these differences is then the stack peak.

If a realloc function is called on a mallocced memory with a new size being
smaller than an old one, total memory of realloc cell is not updated.
This can cause sum of all cells (excluding free) of total memory being
greater than free cell.
.BI \-n\  name \fR,\ \fB\-\-progname= name
Name of the program file to profile.
.BI \-p\  file \fR,\ \fB\-\-png= file
Generate PNG graphic and store it in the file.
.BI \-d\  file \fR,\ \fB\-\-data= file
Generate binary data file and store it in the file.
.BI \-u\fR,\ \fB\-\-unbuffered
Do not buffer output.
.BI \-b\  size \fR,\ \fB\-\-buffer= size
Collect size entries before writing them out.
.BI \fB\-\-no-timer
Do not collect additional information through timer.
.BI \-m\fR,\ \fB\-\-mmap
Also trace mmap and friends.
.BI \-?\fR,\ \fB\-\-help
Print help and exit.
.BI \fB\-\-usage
Print a short usage message and exit.
.BI \-V\fR,\ \fB\-\-version
Print version information and exit.
The following options only apply when generating graphical output:
.BI \-t\fR,\ \fB\-\-time\-based
Make graph linear in time.
.BI \-T\fR,\ \fB\-\-total
Also draw graph of total memory use.
.BI \fB\-\-title= name
Use the name as a title of the graph.
.BI \-x\  size \fR,\ \fB\-\-x\-size= size
Make graphic size pixels wide.
.BI \-y\  size \fR,\ \fB\-\-y\-size= size
Make graphic size pixels high.
Exit status is equal to the exit status of profiled program.
For bug reporting instructions, please see:
.BR memusagestat (1),
.BR (8)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]