Slide 6.9: Variable-length record deletion (cont.)
Slide 6.11: Storage fragmentation combat
Home

Storage Fragmentation


Storage fragmentation is the process, or result, of splitting a large area of free memory (on disk or in main memory) into smaller non-contiguous blocks. This happens naturally when you use a disk frequently, creating, deleting, and modifying files. There are two kinds of fragmentation:

Internal Fragmentation
This occurs when memory is allocated in frames and the frame size is larger than the amount of memory requested. For example,

243   560  
81    12    File Structures:     An Object-Oriented Approach with C++ |0201874016|94.80|360|
52    105   *|-1    g WML   &   WMLScript |1565929470|17.48|12|
62    169         XML in a Nutshell,     2nd Edition|0596002920|39.95|39|
39    243   *|105   nd XSLT |0596001436|26.37|890|
84    294    Mobile  Commerce Systems  |0521797561|29.51|93|                                          
63    390      WAP Development with WML and WMLScript|0672319462|18.99|56|
83    465   Dynamic WAP Application Development     |1930110081|34.59|18|                     
79    560   M Commerce:   Technologies, Services, and Business Models |0471135852|23.09|5|

where the length of the 5th record is 49 but it resides in a record frame of length 84. The extra 35 bytes are filled with spaces. We may put the extra 35 spaces back to the avail list, but this may create external fragmentation.

External Fragmentation
Fragmentation can also refer to memory that has small, unused holes scattered throughout it. For example,

243   560  
81    12    File Structures:     An Object-Oriented Approach with C++ |0201874016|94.80|360|
52    105   *|355   g WML   &   WMLScript |1565929470|17.48|12|
62    169         XML in a Nutshell,     2nd Edition|0596002920|39.95|39|
39    243   *|105   nd XSLT |0596001436|26.37|890|
49    294    Mobile  Commerce  Systems |0521797561|29.51|93|
23    355   *|-1                  
63    390      WAP Development with WML and WMLScript|0672319462|18.99|56|
83    465   Dynamic WAP Application Development     |1930110081|34.59|18|                     
79    560   M Commerce:   Technologies, Services, and Business Models |0471135852|23.09|5|

where the length of the 6th record is 23, which is probably too small for the use of any records. The space is actually on the avail list rather than being locked inside some other record but is too fragmented to be reused.