- Published on
Investigation · Part 16 of 20 · From source to a running process
Why Freeing Memory Does Not Shrink Your Process
I freed 999,000 of one million small blocks and the process did not become one kilobyte smaller. malloc_stats, strace and malloc_trim show why: the heap can only shrink from its top, glibc keeps the free pages, and threads multiply the arenas. Rust behaves the same.