I'm taking an Operating Systems class in C for my Computer Science major.

I am curious if whether or not this has to do with any wasted space when memory is allocated and if whether or not this varies on any computer operating system, and I understand that how memory is arranged can be done so in any order best for the system.

1 Answers

Clifford On

Heap allocations have maximal alignment - typically 8 bytes, so individual allocations have up to 7 bytes "wasted" to ensure alignment.

Then each allocation includes a block of metadata for heap management.

Further in some implementations or debug builds, additional metadata or padding may be included to detect heap errors such as attempts to free non-heap objects or block overrun.