Compaction is a memory management technique that compacts a running system's free space in order to reduce fragmentation and improve memory allocation efficiency. Many modern operating systems, including Windows, Linux, and Mac OS X, use compaction. As shown in the diagram, we have some used memory (in black) and some unused memory (white color). The memory that has been used is combined. All of the empty spaces are combined. This is known as compaction. This is done to avoid fragmentation, but it consumes an inordinate amount of CPU time.