The Wayback Machine - https://web.archive.org/web/20240708012740/https://www.geeksforgeeks.org/difference-between-compaction-and-defragmentation/
Open In App

Difference Between Compaction and Defragmentation

Last Updated : 04 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The technique of collection of all the free space in a contiguous manner to make system and memory run efficiently is known as Compaction or Defragmentation. But as the name suggests there is a small difference between them, let’s look into that minor difference.

Compaction

Compaction is one of the solutions to External Fragmentation. The goal is to shuffle the memory content to place all the free memory together in one block. Compaction is not always possible. If relocation is static and is done at assembly or load time, compaction cannot be done. The simplest compaction algorithm is simply to move all processes towards one end of memory. This scheme can be expensive.

Defragmentation

Defragmentation means storing the complete files in the smallest number of contiguous regions. It means it tries to store files as one complete unit if that size of contiguous memory is available. Defragmentation works by locating file fragments that are scattered and putting them back together. The purpose is to decrease file access time and increase space on the hard drive.

Difference between Compaction and Defragmentation

S.No        

Compaction     

Defragmentation

1. Compaction is a process in which the free space is collected in a large memory chunk to make some space available for processes. It is a process that reduces the degree of fragmentation.
2. Compaction is used to reduce external fragmentation. Defragmentation reduces data access time and allows storage to be used more efficiently. 
3. Compaction is only possible if the relocation is dynamic Some operating systems automatically defragment storage periodically
4. It attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes. It does this by physically organizing the contents of the mass storage device used to store files into the smallest number of contiguous regions
5. Not always easy to perform compaction. Easy to perform Defragmentation. Many tools are available like Disk Defragment etc.


Similar Reads

Difference Between Fragmentation and Compaction
In an operating system, memory management plays a vital role in maximum CPU utilization, when space is allocated to a process there is some loss of memory(fragmentation) leads to inefficient use of memory, and to reduce this loss one of the techniques (compaction) is used to optimize memory space. FragmentationIt occurs due to contiguous memory all
3 min read
Disk Defragmentation in Operating System
In the world of computer storage management, retaining the performance of Hard Disk Drives (HDDs) is important for ensuring easy operation and responsiveness of the running system. One key method used to obtain this is disk defragmentation. As data is written, modified, and deleted on a disk through the years, it will become fragmented, leading to
5 min read
What is Defragmentation?
You all must have heard about the word ‘Defragmentation’ which should be done on Windows whether it is a laptop or a desktop. Defragmentation is an important technique for PC structures aimed at optimizing storage device overall performance. As files are created, modified, and deleted through the years, information fragmentation takes place, causin
7 min read
Compaction in Operating System
Compaction is a technique to collect all the free memory present in the form of fragments into one large chunk of free memory, which can be used to run other processes. It does that by moving all the processes towards one end of the memory and all the available free space towards the other end of the memory so that it becomes contiguous. It is not
3 min read
Difference between Difference Engine and Analytical Engine
Introduction: The development of computing technology has a rich history, with many inventions and innovations leading to the creation of the modern computer. Two such machines, the Difference Engine and Analytical Engine, were created by the English mathematician and inventor Charles Babbage in the 19th century. While these machines share some sim
7 min read
Difference between Voltage Drop and Potential Difference
Voltage Drop is defined as the decrease in the electric potential along the path of current that is flowing in an electric circuit. Voltage drop can be assigned at each point in the electric circuit that is proportional to the electrical elevation. The amount of energy delivered per second to any component in the circuit is equal to the voltage dro
4 min read
Difference Between Electric Potential and Potential Difference
The flow of electric charges is known as electricity, and it is responsible for producing electric current. An important word associated with electricity is electric potential. A potential difference is required to create the flow of electrons and hence, produce electricity. Before understanding the difference between electric potential and potenti
7 min read
Difference and Similarities between PHP and C
PHP is a server-side scripting language designed specifically for web development. It can be easily embedded in HTML files and HTML codes can also be written in a PHP file. The thing that differentiates PHP from a client-side language like HTML is, PHP codes are executed on the server whereas HTML codes are directly rendered on the browser. C is a
3 min read
Difference Between AND Gate and OR Gate
A logic gate is a simple switching circuit that determines whether an input pulse can pass through to the output in digital circuits. The building blocks of a digital circuit are logic gates, which execute numerous logical operations that are required by any digital circuit. These can take two or more inputs but produce only one output. The mix of
3 min read
Difference between Stop and Wait, GoBackN and Selective Repeat
Reliable data transfers are one of the primary concerns in computer networking. This service department lies in the hands of TCP. Their major flow control protocols - Stop and Wait, Go Back N, and Selective Repeat. Stop and Wait ARQ - The sender sends the packet and waits for the acknowledgement of the packet. Once the acknowledgement reaches the s
2 min read