Bash time and programming

I have inherited a C++ program which does not manage it's memory at all. It has a whole bunch of 'new' variables without many deletes. I believe it was the programmers intent to let the OS clean up.

Correct me if I am wrong, but I believe the unix/linux systems clean up after the program finishes running.

What I need to do is print out the time which the program executes, and if possible, I would like to record the clean up time. I would like to do this in a bash script, however, how do I go about this?

The program uses Wang's algorithm as a tree search to put together rectangles into a larger rectangles until it's exhaustive search finds the optimal. So as you can imagine, it can run for a very long time.

Thanks!

There is no way to differentiate "cleanup time"

try running your compiled code like this

time myprogram arg1 arg2 

And yes, once a process ends the programs allocated memory is reclaimed.