memusage(1) memusage(1) (NAME) memusage - (SYNOPSIS) memusage []... []... (DESCRIPTION) memusage (bash) program . libmemusage.so LD_PRELOAD ( ld.so(8) ) . libmemusage.so malloc(3) calloc(3) free(3) realloc(3) mmap(2) mremap(2) munmap(2) . memusage memusagestat(1) ( -p ) PNG . (Memory usage summary) << >> (Memory usage summary) memusage : (heap total) size malloc(3) (nmemb*size) calloc(3) length mmap(2). realloc(3) mremap(2) ( ) . (heap peak) size malloc(3) nmemb*size calloc(3) size realloc(3) length mmap(2) new_size mremap(2). (stack peak) ( ) . . (stack peak) . . realloc(3) mremap(2) <> <> . realloc(3) <> ( 0 ). <> memusage realloc(3) . <> ( <>) <> . (Histogram for block sizes) << >> (buckets) . (OPTIONS) -n name, --progname=name . -p file, --png=file PNG file. -d file, --data=file file. -u, --unbuffered . -b size, --buffer=size size . --no-timer (SIGPROF) . -m, --mmap mmap(2) mremap(2) munmap(2) . -?, --help . --usage . -V, --version . : -t, --time-based ( ) X. -T, --total . --title=name name . -x size, --x-size=size size . -y size, --y-size=size size . (EXIT STATUS) memusage . (BUGS) : (EXAMPLES) . memusage.png : $ memusage --data=memusage.dat ./a.out ... Memory usage summary: heap total: 45200, heap peak: 6440, stack peak: 224 total calls total memory failed calls malloc| 1 400 0 realloc| 40 44800 0 (nomove:40, dec:19, free:0) calloc| 0 0 0 free| 1 440 Histogram for block sizes: 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% ================ $ memusagestat memusage.dat memusage.png (Program source) #include #include #define CYCLES 20 int main(int argc, char *argv[]) { int i, j; size_t size; int *p; size = sizeof(*p) * 100; printf("malloc: %zu\n", size); p = malloc(size); for (i = 0; i < CYCLES; i++) { if (i < CYCLES / 2) j = i; else j--; size = sizeof(*p) * (j * 50 + 110); printf("realloc: %zu\n", size); p = realloc(p, size); size = sizeof(*p) * ((j + 1) * 150 + 110); printf("realloc: %zu\n", size); p = realloc(p, size); } free(p); exit(EXIT_SUCCESS); } (SEE ALSO) memusagestat(1), mtrace(1), ld.so(8) Linux man-pages 6.9.1 2024-06-15 memusage(1)