Freed, Not Returned: A Blowup in Mere's Runtime, mmap on macOS, and a Fixed Threshold on Linux
A Ruby implementation written in my language Mere, run under a test that collects every 50 safepoints, passed 6 GB and kept going. There were three causes. One was a quadratic walk in the runtime. Another was macOS's malloc: today's macOS keeps freed memory in both the resident size and the footprint, and gives none of it back when asked, so region blocks of 16 KB or more are now mapped and unmapped. I first decided Linux needed nothing, because glibc returns large blocks -- then measured, and Linux passed 6 GB in 17 seconds: glibc's mmap threshold rises once a mapped block is freed. A program now fixes it when it starts. Nothing is freed later than before, ordinary programs run at the same speed, and the programs that blew up hold 24-31% less. I got it wrong twice along the way.