CS 224 Lab 4 - Memory Management

Objectives:

  1. The memory management applet illustrates a heap manager using the first-fit mechanism.

    Try the memory calls below and make sure that you understand what is happening.
            p1=m.allocate(4)
            p2=m.allocate(2)
            m.deallocate(p1)
            p3=m.allocate(1)
     
  2. Now try
           
    p1=m.allocate(4)
           
    p2=m.allocate(1)
            m.deallocate(p1)
            p3=m.allocate(5)

    Why does this fail even though there are more than 6 cells of free memory?


  1.  
    Assignment:
    The problem above can be solved by heap compaction. Modify the code so that it performs heap compaction. Be sure that you modify the values of the addresses of already allocated variables if the block is moved!

 

  1. Send me your modified zipped project in the dropbox in BlackBoard.