Laboratory Exercises For Computer Science 213

Laboratory on Memory Management

Laboratory on Memory Management

Goals: This laboratory exercise provides practice with memory management algorithms.


Suppose a computer memory contains 64 units of space. Consider the following sequence of memory requests.


Allocate:   A 10
Allocate:   B 8
Allocate:   C 15
Allocate:   D 12
Deallocate: A
Allocate:   E 11
Deallocate: C
Allocate:   F 8
Allocate:   G 8
Deallocate: D
Suppose that this sequence of requests was handled by each of the following allocation algorithms. Show the resulting configuration of memory, together with all appropriate pointers and flags. Assume that adjacent blocks of free memory are NOT coalesced.

  1. First-fit
  2. Next-fit (circular free list kept with pointer to last free block)
  3. Best-fit (free list kept in ascending order of block size)
  4. Worst-fit (free list kept in descending order of block size)
  5. Binary-buddies

Suppose the first-fit algorithm were combined with the boundary tag buddy approach to allow for more efficient coalescing of free space.

  1. Show the resulting memory configuration, together with all appropriate pointers and flags.


Each memory allocation has special advantages and disadvantages.

  1. Can you find a sequence of allocations and deallocations that can be satisfied by the boundary-tag buddy algorithm, but which cannot be met by the binary-buddy algorithm, due to difficulties of internal fragmentation?

  2. Can you find a sequence of allocations and deallocations that can be satisfied by the binary-buddy algorithm, but which cannot be met by the boundary-tag buddy algorithm, due to difficulties of external fragmentation?

This document is available on the World Wide Web as

     http://www.math.grin.edu/~walker/courses/213.fa98/lab-memory.html

created November 10, 1998
last revised November 10, 1998