CPW Part 11: Region-based Memory Management

Quiz 24

Implement the module for memory management as shown in the video. If you find bugs fix them ;-) Make sure that the memory managed by the module will be freed before programs using the module terminate if they follow the convention that before termination finalize() gets called.

Use the module for the calculator:

  • Remove debugging output from the region-based memory management (or only produce debug information if some special macro is defined).

  • Constructors for types struct Expr should allocate memory with allocFromMemRegion().

  • Remove the destructor deleteExpr() from the module for expression nodes.

  • Add a function deleteAllExpr() that releases all memory allocated for expression nodes.

  • Make sure that there are no memory leaks in the calculator. Validate this with valgrind.

  • In the lcc compiler the parameter corresponding to our enum constant for extra capacity is 10K (\(10 * 1024\)). For the quiz leave it a 64. It makes it easier to write tests this way.

How to Submit

You have to submit a tarball quiz24.tgz of your project. In your project directory do the following:

  • Run make clean

  • Create the tarball with

    1
    tar cfvz quiz24.tgz *
    
  • On theon you can submit the tarball with submit hpc quiz24 quiz24.tgz