This preview shows page 1. Sign up to view the full content.
Unformatted text preview: e the heap as a large array of bytes and a pointer p that initially points to the ﬁrst byte of the array. To allocate size bytes, malloc would save the current value of p on the stack, increment p by size, and return the old value of p to the caller. Free would simply return to the caller without doing anything. This naive allocator is an extreme point in the design space. Since each malloc and free execute only a handful of instructions, throughput would be extremely good. However, since the allocator never reuses any blocks, memory utilization would be extremely bad. A practical allocator that strikes a better balance between throughput and utilization must consider the following issues: ¯ ¯ ¯ ¯ Free block organization: How do we keep track of free blocks? Placement: How do we choose an appropriate free block in which to place a newly allocated block? Splitting: After we place a newly allocated block in some free block, what do we do with the remainder of the free block? Coalescing: What do we do with a block that has just been freed? Th...
View Full Document
- Spring '10
- The American