Blogger Tricks

15 May 2012

Memory Compaction / Compaction

To place all free memory together in one large block, the memory content is shuffled.

 
3 holes of size 100k,300k and 260k can be compacted into one hole of size 560k.


Compaction is not always possible:

we moved processes p4 and p3. To execute these processes in their new location all internal address must be relocated.

If relocation is static and done at load time then compaction can’t be done. Compaction is possible only if relocation is dynamic and done at execution time.

Problem: selection of optional compaction strategy is difficult.


MEMORY MANAGEMENT WITH BIT MAPS

With a bit map, memory is divided up into allocation units, which is as small as a few words and can be as large as several kilobytes.
Bit map contains one bit for each allocation unit. This bit is  if the corresponding unit is free and  if it is occupied( can be used to indicate occupied unit and 1 for free unit) 

The size of the allocation unit is an important design issue. The smaller the allocation unit the larger the bitmap. However even with an allocation unit as small as 4 bytes (32 bit) 32 bit of memory will require only one bit require.

A memory of 32 bit n amp bits so the bitmap will take up only 1/33 of memory.

If the allocation units is chosen large, the bit map will be smaller, but appreciable memory may be wasted in the last unit if the process size is not n exact multiple of the allocation unit.

A bit map provides a simple way to keep track of memory words in a fixed amount of memory because the size of the bit map depends only on the size of memory and the size of the allocation unit.

The main problem with it is that when it has been decided to bring a k unit process into   memory, the memory manager must search the bit map to find a run of k consecutive 0 bits in the map.

Searching a bit map for a run of a given length is a slow operation, this is an argument against bit maps.