CS 368: A Little Purify Example

generated by Karen


The following 3 files comprise a very small example that produces a memory leak of a single integer. The files are:

testpurify.cpp,
testObject.cpp, and
testObject.h

Try the following exercise to use purify.

  1. Copy the 3 files to your own directory.
  2. Compile an instrumented executable with
       purify g++ -g testpurify.cpp testObject.cpp -o testpurify
    
  3. Run the testpurify program. Play with the various buttons to see what you get. When the program finishes, you will see that there are 4 bytes of leaked memory. This corresponds to one integer.
  4. Look at the code, and understand why there is the leaked memory of a single integer.
  5. Fix your copy of the code, to eliminate the memory leak.
  6. Recompile (an instrumented version), and re-run to check your fix.