Heap Allocation .
. Fill a request of size s with block of size s ' where s ' is the smallest size greater than or equal to s
. For large blocks of storage use heap manager
. For large amount of storage computation may take some time to use up memory so that time taken by the manager may be negligible compared to the computation time
As mentioned earlier, for efficiency reasons we can handle small activations and activations of predictable size as a special case as follows:
1. For each size of interest, keep a linked list if free blocks of that size
2. If possible, fill a request for size s with a block of size s', where s' is the smallest size greater than or equal to s. When the block is eventually de-allocated, it is returned to the linked list it came from.
3. For large blocks of storage use the heap manger.
Heap manger will dynamically allocate memory. This will come with a runtime overhead. As heap manager will have to take care of defragmentation and garbage collection. But since heap manger saves space otherwise we will have to fix size of activation at compile time, runtime overhead is the price worth it.
|