10.9.4 Fragmentation Fragmentation:分成碎片
21 10.9.4 Fragmentation Fragmentation: 分成碎片
Fragmentation Poor memory utilization caused by fragmentation Comes in two forms: internal fragmentation external fragmentation 22
22 Fragmentation • Poor memory utilization caused by fragmentation – Comes in two forms: • internal fragmentation • external fragmentation
Internal fragmentation Internal fragmentation For some block internal fragmentation is the difference between the block size and the payload size block Interna Internal fragmentation payload fragmentation
23 Internal Fragmentation • Internal fragmentation – For some block, internal fragmentation is the difference between the block size and the payload size payload Internal fragmentation block Internal fragmentation
Internal fragmentation Internal fragmentation Is caused by overhead of maintaining heap data structures, padding for alignment purposes, or explicit policy decisions(e.g, not to split the Depends only on the pattern of previous requests, and thus is easy to measure 24
24 Internal Fragmentation • Internal fragmentation – Is caused by overhead of maintaining heap data structures, padding for alignment purposes, or explicit policy decisions (e.g., not to split the block). – Depends only on the pattern of previous requests, and thus is easy to measure
External fragmentation Occurs when there is enough aggregate heap memory, but no single free block is large enough 1=ma11oc(4) 「「「「「「 p2 malloc(5) p3 malloc(6) free(p2) p4= malloc(6)
25 External fragmentation • Occurs when there is enough aggregate heap memory, but no single • free block is large enough p1 = malloc(4) p2 = malloc(5) p3 = malloc(6) free(p2) p4 = malloc(6)