Sunday, November 16, 2008

Fundas of Contiguous Memory Allocation - Part I

Through Contiguous Memory Allocation, the memory manager strictly allocates contiguous memory locations to an object loaded in the memory. The Contiguous Memory Allocation can be done in two ways, static and dynamic.



In the Static Memory Allocation, the memory is divided into equal sized partitions and objects are loaded into these partitions as the processes ask for them. With this type of memory allocation, we see a fragmentation that is known as internal fragmentation that occurs when a small object is loaded into a partition of a larger size. The space that is not occupied by the object cannot be allocated to another object and hence is wasted.

In case of Dynamic Memory Allocation, the internal fragmentation is eliminated by making each partition only as large as necessary for a particular object. When an object is removed from memory, the space occupied by it is returned to the pool of available memory spaces. However, in this case, a fragmentation known as External Fragmentation is observed because over the time, dynamic partitioning 0f memory has a tendency to fragment memory into interspersed areas of allocated and unused memory. As these areas are not contiguous, allocation may fail to find a free region to honor a request, even when the combined size of the free memory exceeds the need of the object by a wide margin.

Another type of fragmentation that can be seen in case of contiguous memoy allocation is the table fragmentation. This is attributed to the space occupied by the data structures needed for operation of the memory manager.

No comments: