As processes are loaded and removed from memory, the free memory space is broken into little pieces.
It happens after sometimes that processes cannot be allocated to memory blocks considering their small size and memory blocks remains unused. This problem is known as Fragmentation.
Fragmentation occurs naturally when you use a disk frequently, creating, deleting, and modifying files.
At some point, the operating system needs to store parts of a file in non-contiguous clusters.
This is entirely invisible to users, but it can slow down the speed at which data is accessed because the disk drive must search through different parts of the disk to put together a single file.
Fragmentation occurs three forms:
§ Internal Fragmentation
§ External Fragmentation
§ Data Fragmentation
§ Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks.
§ Allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.
§ This occurs in fixed partitioning. Internal Fragmentation occurs because the memory is wasted within the space allocated to process that internal to a partition.
§ External Fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used.
§ If too much external fragmentation occurs, the amount of usable memory is drastically reduced. Total memory space exists to satisfy a request, but it is not contiguous.
§ For example, consider a situation where in a program allocates 3 continuous blocks of memory and then frees the middle block.
§ The memory allocator can use this free block of memory for future allocations. However, it cannot use this block if the memory to be allocated is larger in size than this free block.
§ Data Fragmentation occurs when large memory files are divided into smaller pieces and/or an OS tries to allocate large files to an external fragmented storage.
§ For example, when a user creates new files and performs different operations like deleting, modifying the files, extremely small spaces are expected to hold new data files.
§ However, if these new files require more overhead, the OS must seek storage that is greater than average.