Why malloc always does more than I asked for

Why malloc always does more than I asked for?

Why malloc always does more than I asked for

I discovered that requesting 13 bytes from malloc triggers complex under-the-hood operations involving headers, back pointers, and padding to ensure proper memory alignment. Building a custom allocator revealed how metadata is essential for freeing individual blocks and how internal fragmentation occurs due to alignment gaps. This journey explains why memory management in C requires more than just moving a cursor forward.

Those padding bytes between the metadata and my actual object are just sitting there, unused, for the entire lifetime of the allocation.

More from this day

2026-07-23