Prashanth L.A.
2023-09-06
OS illusion: memory virtualization
Dynamic relocation via base and bounds
Segmentation
Â
free-space management
Needed by
| Strategy | Description |
|---|---|
| Best Fit | Find free chunks that are bigger than the request and return the smallest |
| Worst Fit | Find the largest free chunk, allocat and keep the remaining chunk on free list |
| First Fit | Find the first chunk that is big enough, remaining free space goes to the list |
| Next Fit | Find the first chunk that is big enough for the request; Searching from the point where one was looking last |
free() does not take a size parameter. So, how does malloc library know the size of memory region to free up?
Answer: Store extra information in a header
Header contains the size of the allocated memory region, and a magic number for integrity checking
Heap with one free chunk
Heap after an allocation for 100 bytes (+ 8 byte
header)