March 1, 2026
72KB to start the party
Why is the first C++ (m)allocation always 72 KB?
C++ apps grab 72KB at launch? Devs cry “not always” and demand receipts
TLDR: A blog claims C++ programs grab 72KB at startup to stash emergency memory for error handling. Commenters split: some demand the author’s code, others argue it’s compiler-specific, and a hot take insists the pool should be static or tunable—making this a design debate with real-world implications.
A curious coder poked at C++ programs and found a weird pattern: the very first memory grab is always 72KB. The plot twist? It’s the C++ standard library quietly prepping an “emergency pool” so it can still throw error messages even if the computer runs out of memory. Sounds smart, right? The crowd… isn’t exactly clapping.
The comments exploded. One skeptic demanded receipts, asking where the code is and combing the author’s GitHub for proof. Another fired off a design hot take: if it’s emergency memory, why not make it fixed upfront? “Make it static or let us tune it,” they fumed, dubbing it the “72KB startup tax.” Then came the buzzkill: “This is compiler-specific,” warned a veteran, raining on the “always” claim. And the pedants arrived with knives out: learn what “always” means, snapped one commenter, triggering a mini thread of technical nitpicking.
Meanwhile, jokers turned it into a meme: C++ carries a “72KB go-bag,” an “emergency snack stash,” and “exception insurance.” Some cheered the safety net. Others called it memory hoarding in disguise. Verdict from the crowd? The mystery is solved, but the drama over design choices, proof, and wording is just getting warmed up.
Key Points
- •A custom allocator preloaded via LD_PRELOAD logs that the first allocation in tested programs is 73728 bytes (72 KB).
- •gdb backtraces indicate the initial 72 KB allocation originates from libstdc++ during early startup.
- •The C++ standard library pre-allocates an “emergency pool” for exceptions to ensure memory is available even if malloc fails.
- •The dynamic linker (RTLD) uses a minimal malloc before libc loads; breakpoints must target the program’s allocator to avoid confusion.
- •Safe logging within a custom malloc was implemented using stack buffers and low-level system calls to prevent recursive allocation loops.