.\" License along with this manual; if not, see
.\" <http://www.gnu.org/licenses/>.
.\" %%%LICENSE_END
-.TH MEMUSAGE 1 2014-09-06 "GNU" "Linux user manual"
+.TH MEMUSAGE 1 2019-03-06 "GNU" "Linux user manual"
.SH NAME
memusage \- profile memory usage of a program
.SH SYNOPSIS
of the collected data.
.SS Memory usage summary
The "Memory usage summary" line output by
-.BR memusage
+.B memusage
contains three fields:
.RS 4
.TP
.BR realloc (3),
the additional field "free" shows reallocations that
caused a block to be freed (i.e., the reallocated size was 0).
-
-
+.PP
The "realloc/total memory" of the table output by
.B memusage
does not reflect cases where
Generate binary data file and store it in
.IR file .
.TP
-.BI \-u\fR,\ \fB\-\-unbuffered
+.B \-u\fR,\ \fB\-\-unbuffered
Do not buffer output.
.TP
.BI \-b\ size \fR,\ \fB\-\-buffer= size
.I size
entries before writing them out.
.TP
-.BI \fB\-\-no-timer
+.B \fB\-\-no-timer
Disable timer-based
.RB ( SIGPROF )
sampling of stack pointer value.
.TP
-.BI \-m\fR,\ \fB\-\-mmap
+.B \-m\fR,\ \fB\-\-mmap
Also trace
.BR mmap (2),
.BR mremap (2),
and
-.BR mmap (2).
+.BR munmap (2).
.TP
-.BI \-?\fR,\ \fB\-\-help
+.B \-?\fR,\ \fB\-\-help
Print help and exit.
.TP
-.BI \fB\-\-usage
+.B \-\-usage
Print a short usage message and exit.
.TP
-.BI \-V\fR,\ \fB\-\-version
+.B \-V\fR,\ \fB\-\-version
Print version information and exit.
.TP
The following options apply only when generating graphical output:
.TP
-.BI \-t\fR,\ \fB\-\-time\-based
+.B \-t\fR,\ \fB\-\-time\-based
Use time (rather than number of function calls) as the scale for the X axis.
.TP
-.BI \-T\fR,\ \fB\-\-total
+.B \-T\fR,\ \fB\-\-total
Also draw a graph of total memory use.
.TP
.BI \fB\-\-title= name
pixels high.
.SH EXIT STATUS
Exit status is equal to the exit status of profiled program.
+.SH BUGS
+To report bugs, see
+.UR http://www.gnu.org/software/libc/bugs.html
+.UE
.SH EXAMPLE
Below is a simple program that reallocates a block of
memory in cycles that rise to a peak before then cyclically
After compiling the program and running the following commands,
a graph of the memory usage of the program can be found in the file
.IR memusage.png :
-
+.PP
.in +4n
-.nf
-$ \fBmemusage --data=memusage.dat ./a.out\fP
+.EX
+$ \fBmemusage \-\-data=memusage.dat ./a.out\fP
\&...
Memory usage summary: heap total: 45200, heap peak: 6440, stack peak: 224
total calls total memory failed calls
calloc| 0 0 0
free| 1 440
Histogram for block sizes:
- 192-207 1 2% ================
+ 192\-207 1 2% ================
\&...
- 2192-2207 1 2% ================
- 2240-2255 2 4% =================================
- 2832-2847 2 4% =================================
- 3440-3455 2 4% =================================
- 4032-4047 2 4% =================================
- 4640-4655 2 4% =================================
- 5232-5247 2 4% =================================
- 5840-5855 2 4% =================================
- 6432-6447 1 2% ================
+ 2192\-2207 1 2% ================
+ 2240\-2255 2 4% =================================
+ 2832\-2847 2 4% =================================
+ 3440\-3455 2 4% =================================
+ 4032\-4047 2 4% =================================
+ 4640\-4655 2 4% =================================
+ 5232\-5247 2 4% =================================
+ 5840\-5855 2 4% =================================
+ 6432\-6447 1 2% ================
$ \fBmemusagestat memusage.dat memusage.png\fP
-.fi
+.EE
.in
.SS Program source
-.nf
+.EX
#include <stdio.h>
#include <stdlib.h>
int i, j;
int *p;
- printf("malloc: %zd\\n", sizeof(int) * 100);
+ printf("malloc: %zd\en", sizeof(int) * 100);
p = malloc(sizeof(int) * 100);
for (i = 0; i < CYCLES; i++) {
else
j--;
- printf("realloc: %zd\\n", sizeof(int) * (j * 50 + 110));
+ printf("realloc: %zd\en", sizeof(int) * (j * 50 + 110));
p = realloc(p, sizeof(int) * (j * 50 + 100));
- printf("realloc: %zd\\n", sizeof(int) * ((j+1) * 150 + 110));
+ printf("realloc: %zd\en", sizeof(int) * ((j+1) * 150 + 110));
p = realloc(p, sizeof(int) * ((j + 1) * 150 + 110));
}
free(p);
exit(EXIT_SUCCESS);
}
-.fi
-.SH BUGS
-To report bugs, see
-.UR http://www.gnu.org/software/libc/bugs.html
-.UE
+.EE
.SH SEE ALSO
.BR memusagestat (1),
.BR mtrace (1)