malloc_stats(3)
β¨ malloc_stats β bestie, we're counting your memory β¨
okay so this is malloc_stats(3), a lil function from the Standard C library (that's libc, link it with -lc). she's not flashy, she's not famous, but she will spill all your memory tea to the terminal. π
πΈ SYNOPSIS πΈ
#include <malloc.h>
void malloc_stats(void);
that's literally it. no arguments, no return value, no drama. she takes nothing and gives you a full report. iconic behaviour honestly. π
π DESCRIPTION π
The malloc_stats() function prints β on standard error, not stdout, remember that bestie β statistics about memory allocated by malloc(3) and related functions.
ngl the way she formats it is very thorough. for each arena (that's an allocation area, think of it like each arena is its own lil memory neighborhood ποΈ), she prints:
- the total amount of memory allocated, and
- the total number of bytes consumed by in-use allocations.
and in case you were wondering where you've seen those two numbers before β they correspond to the arena and uordblks fields you'd get from mallinfo(3). yeah. same numbers. she's just serving them directly. β¨
plus, because she's generous, she also prints:
- the sum of those two statistics across all arenas, and
- the maximum number of blocks and the maximum number of bytes that were ever simultaneously allocated using
mmap(2).
so it's a whole vibe check on your heap. past and present. peak usage included. π₯
π ATTRIBUTES π
if you don't know what "attributes" even means here, go read attributes(7) for the full explanation, but tl;dr:
malloc_stats()β Thread safety βMT-Safe
MT-Safe means you can call her from multiple threads, no cap. π«Ά
π STANDARDS π
- GNU.
that's the whole standard section. she's a GNU girlie, she said it once and she meant it. π
π¦ HISTORY π¦
- glibc 2.0.
she's been here since glibc 2.0. an OG. a legend. respect her. π
π NOTES π
so if you want more detailed information about memory allocations in the main arena specifically β like, the deep lore, not just the summary β you get that with mallinfo(3).
malloc_stats() gives you the β¨overviewβ¨. mallinfo(3) gives you the dissertation. pick your fighter. π
β SEE ALSO β
go read them. she said so. π
and that's the whole page bestie, mwah π this was Linux man-pages 6.20, dated 2026-02-08, and it lives at malloc_stats(3). take care of ur memory and ur memory will take care of u. π«Άβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2012, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms