February 27, 2026
Paging Dr. Drama
How to Allocate Memory
Programmer says ditch one‑size‑fits‑all memory; Windows devs clap back
TLDR: A coder argues you can speed programs up by tailoring how you request memory for specific tasks instead of using one generic method. Commenters split fast: a Windows dev fact-checked the page talk, others cheered the speed claims or mocked the Linux-centric vibe—turning a memory lesson into a platform skirmish.
A low-level coding guru dropped a spicy take: don’t just grab “memory” with malloc() and free()—allocate for what you’re actually using (pages, stacks, arrays, fixed‑size objects) and you could see 2–20× speed-ups. He even side‑eyed the classic one‑allocator-fits-all approach (sorry jemalloc and dlmalloc) and claimed separate allocators per data pattern are the real power move. He showed page tricks with mmap, stack bursts with alloca, and even floated “tries over hash tables” heresy.
Cue the comments. One Windows dev stormed in with the actually: that whole “often the OS gives you pages” line? Not on Windows like that, noting you can’t just shuffle 4K pages around and you’re stuck with bigger chunks. The mood flipped from “Nice reference!” to “Linux brain detected.” Others joked about “allocating drama” and begged for plain English, while performance fans cheered the 2–20× boast like it was a race car. Meanwhile, the author’s casual “I don’t use size_t” line sparked eyebrow Olympics, and old‑schoolers waxed nostalgic about ancient sbrk magic.
In short: pragmatists vs. pedants, Linux vs. Windows, and a whole lot of “premature optimization” vs. “ship faster code.” The post was about memory; the comments were about memory—and egos—running wild.
Key Points
- •The article advocates allocating memory by usage pattern (pages, stacks, arrays, objects) rather than via a single general-purpose allocator.
- •Using separate allocators tailored to each data structure or usage pattern can deliver substantial performance gains over generic malloc/free.
- •Type-specific wrappers around malloc (e.g., alloc_foo) enable profiling and later substitution with specialized allocators.
- •Page-level allocation is demonstrated using mmap for allocation and munmap for releasing contiguous virtual memory.
- •Stack allocation options include compiler extensions like alloca/_alloca and POSIX sigaltstack; UNIX also offers sbrk to adjust the process break.