Where did my freed memory (not) go?
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
Yapfast's author found that freeing memory in a Rust app on Linux with glibc barely lowered the kernel's count: heap in use fell from 78 to 55 MiB, but anonymous memory stayed near 97 MiB. The cause was 47 malloc arenas holding free chunks, and freed space in the middle of a heap is not returned. Capping arenas at 2 cut about 8 MiB, and targeted malloc_trim calls recovered more. These figures come from one app, mostly on Linux, and Windows is unmeasured.