External fragmentation External fragmentation depends on the pattern of future requests and thus is difficult to measure
26 External fragmentation • External fragmentation depends on – the pattern of future requests – and thus is difficult to measure
10.9.5 Implementation Issues
27 10.9.5 Implementation Issues
Implementation issues How do we know how much memory to free just given a pointer? How do we keep track of the free blocks? 0 free(po) pl malloc(1)
28 Implementation issues • How do we know how much memory to free just given a pointer? • How do we keep track of the free blocks? p1 = malloc(1) p0 free(p0)
Implementation issues What do we do with the extra space when allocating a structure that is smaller than the free block it is placed in? How do we pick a block to use for allocation many might fit? How do we reinsert freed block Reinsert:重新插入
29 Implementation issues • What do we do with the extra space when allocating a structure that is smaller than the free block it is placed in? • How do we pick a block to use for allocation – many might fit? • How do we reinsert freed block? Reinsert:重新插入
Knowing how much to free Standard method keep the length of a structure in the word receding the structure This word is often called the header field or header requires an extra word for every allocated structure
30 Knowing how much to free • Standard method – keep the length of a structure in the word preceding the structure • This word is often called the header field or header – requires an extra word for every allocated structure