Fragmentation refers to the condition of disk in which files are divided into pieces scattered around the disk. Fragmentation occurs naturally when we use a disk frequently, creating, deleting and modifying files.
There are two types of fragmentation

1. Internal Fragmentation 
  • It occurs with all memory allocation strategies. This is caused by the fact that memory is allocated in blocks of a fixed size, wheres the actual memory needed will rarely be that exact size. For a random distribution of memory requests, on the average 1/2 block will be wasted per memory request, because on the average the last allocated block will be only half null. 
  • Note that the same effect happens with hard drives, and that modern hardware gives us increasingly larger drives and memory at the expense of ever larger block size, which translate to more memory lost to internal fragmentation. 
  • Some system use variable size blocks to minimize losses due to internal fragmentation. 


2. External Fragmentation 
  • External fragmentation means that the available memory is broken up into lots of little pieces, none of which is big enough to satisfy the next memory requirement, although the same total could. 
  • All the memory allocation strategies suffer from external fragmentation, though first and best fits experience the problems more so than worst fit. The amount of memory lost to fragmentation may very with algorithm, usage patterns, and some design decision such as which end of a hole to allocate and which end to save on the free list. 
  • Statistical analysis of first fit, for example, shows that for N blocks of allocated memory, another 0.5 N will be lost to fragmentation. 
  • If the program in memory are relocatable, then the external fragmentation problem can be reduced via compaction, i.e. moving all processes down to one end of physical memory. This only involves updating the relocation register for each process, as all internal work is done using logical addresses.