2. 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 after many blocks have been allocated and freed. For example, if there is 3 kilobytes of free space and two 1k blocks are allocated and then the first one (at the lowest address) is freed, then there will be 2k of free space split between the two 1k blocks. The maximum size block that could then be allocated would be 1k, even though there was 2k free. The solution is to "compact" the free space by moving the allocated blocks to one end (and thus the free space to the other).
As modern file systems are used and files are deleted and created, the total free space becomes split into smaller non-contiguous blocks (composed of "clusters" or "sectors" or some other unit of allocation). Eventually new files being created, and old files being extended, cannot be stored each in a single contiguous block but become scattered across the file system. This degrades performance as multiple seek operations are required to access a single fragmented file.
Defragmenting consolidates each existing file and the free space into a continuous group of sectors. Access speed will be improved due to reduced seeking.
The rate of fragmentation depends on the algorithm used to allocate space and the number and position of free sectors. A nearly-full file system will fragment more quickly.
See garbage collection.