A first-in-last-out (LIFO) structure removes the most recently added item first. Stack storage follows this order, supporting contiguous data and automatic deallocation when data goes out of scope. Heap allocations do not necessarily follow LIFO order, and freeing them can leave unusable gaps. section 2.8 section 3.1
Heap holes
Allocate arrays of 1 KB, 2 KB, and 1 KB, then delete the first and third. Although 2 KB is free in total, the two separate 1 KB holes cannot hold a 1.5 KB array. section 3.1
Figure 3.4 We have 2048 bytes of memory free, but if we try to allocate an array of 1536 bytes, we’ll run out of memory because the biggest contiguous space is 1024 bytes.

Shows how fragmented free space can prevent a large allocation even when total free memory is sufficient. section 3.1


