Dynamic Storage Allocation Techniques
Again Freestudy9 Comes with new post related to Dynamic Storage Allocation Techniques. Additionally, we had tried to make it as possible as easy.
There two techniques used in dynamic memory allocation and those are –
- Explicit allocation
- Implicit allocation
Explicit Allocation ( Dynamic Storage Allocation Techniques )
The explicit allocation can do for fixed size and variable sized blocks.
Explicit Allocation of Fixed Size Blocks
- This is the most straightforward technique of explicit allocation in which the size of the block for which memory allocated fixed.
- In this technique, a free list used. An open file is a set of free blocks. This observed when we want to allocate memory. If some memory deallocated, then the free list gets de-allocated appended.
- The blocks linked to each other in a list structure. The memory allocation can do by pointing the previous node to the newly allocated block. Memory denoted-allocation can be done by de-referencing the previous link.referencing
- The pointer which points to the first block of memory called Available.
- This memory allocation and deallocation were done using heap memory de-allocation.
YOU ALSO LIKE Complex Code
- The explicit allocation consists of taking a block off the list, and de-allocation consist of allocation putting the block back on the list.
The advantage of this technique is that there is no space overhead.
Explicit Allocation of Variable Sized Blocks
- Due to frequent memory allocation and deallocation, the heap memory becomes de-allocation fragmented. That means heap may consist of some blocks that are free and some that allocated.
- In Fig. A fragmented heap memory shows. Suppose a list of 7 blocks gets allocated and second, a fourth and sixth block dead-allocated then fragmentation occurs.
- Thus, we get variable sized blocks that available free. For allocating variable sized blocks some strategies such as the first fit, worst fit and best fit used.
- Sometimes all the free blocks collected together to form a sizeable free block. This ultimately avoids the problem of fragmentation.
Implicit Allocation: Dynamic Storage Allocation Techniques
- The implicit allocation performed using user program and runtime packages.
- The runtime package required to know when the storage block not in use.
- The format of storage block as shown in Fig
- There two approaches used for implicit allocation.
Reference count: Dynamic Storage Allocation Techniques
- The reference counts a single counter used during implicit memory allocation. If any block referred by some another block, then its reference count incremented by one.
- That also means if the reference count of particular block drops down to 0 then, that means that chunk not referenced one and hence it can de-allocated. Reference counts best allocated. It used when pointers between blocks never appear in a cycle.
Marking Techniques: Dynamic Storage Allocation Techniques
- This is an alternative approach to determine whether the block is in use or not. In this method, the user program suspended temporarily, and frozen pointers used to mark the blocks that in use.
- Thus, sometime bitmaps used. These pointers then placed in the heap memory.
- Again we go through her mind and mark those blocks which mark unused.
- There is one more technique called compaction in which all the used blocks moved at the one end of heap memory. So, that all the free blocks available in one sizeable free chunk.