In this tutorial, I am going to explain one of the methods of dynamic memory management that is name as compaction. In this process, all marked or used node is shifted to one end and variable or available memory is kept at another end.
In a very simple language, the compaction is a process in which we mode all the used node to the one end of the memory and all the available memory to the other end. And the algorithm to perform such operation is called compaction algorithm.
In this scheme initially, memory is one large block of available storage. When requests arrive for storage, a block of memory is allocated sequentially starting from the first location in the memory as shown in Fig1.
A variable free point contains the address of the first location following the last block allocated as in Fig1, a free point equals 950. When a block is freed, the free point remains unchanged and no combination of free spaces take place.
When a block of size n is allocated free point is increased by n. This continues until a block of size n is requested and free point+ n-1 is larger than the highest address in the memory. The request can not be satisfied without further action being taken.
At that point, user routines come to a halt and system compaction routine is called. this routine copies all allocated blocks into sequential memory locations starting from the lowest address in the memory.
Thus all free blocks that were interspersed with allocated blocks are eliminated, and the free point is reset to the sum of the size of all the allocated blocks. thus, one large free block is created at the upper end of the memory and the user request may be filled if there is sufficient storage available. this process is shown in Fig1 on a memory of 1024 words.
When allocated blocks are copied into a lower portion of memory, special care must be taken so that pointer value remains correct. for example, the contents of memory location 420 in allocated block 2 of Fig1 might contain the address340. After block2 is moved to locations 125 through 299, 420 to 220, those content must be changed to 140.
Memory compaction is the process to shift all the free memory at one end and used or marked node at one end so that when a request memory is less than the size of free pool memory then we can easily allocate the memory to that block.
In the case of any queries, you can write to us at firstname.lastname@example.org we will get back to you ASAP.
Hope! you would have enjoyed this post about memory compaction.
Please feel free to give your important feedbacks in the comment section below.
Have a great time! Sayonara!
- How To Quickly Cut Tree Background In Photoshop?
- WWW In Hindi: World Wide Web In Hindi, WWW हिंदी में.
- The Leaky Bucket Algorithm In Hindi.Leaky Bucket Algorithm हिंदी में
- TCP vs UDP In Hindi: Difference between TCP and UDP In Hindi, TCP और UDP में अंतर हिंदी में
- UDP: User Datagram Protocol
- Mail Merge In Hindi: How To Make Notice Using Excel Data In Word Template 2020? , Mail Merge हिंदी में?
- Multicast Routing
- IPv4 vs IPv6
- Classful Addressing vs Classless Addressing
- Unicast Routing Protocol