There's no automatic way, you have to manually delete whatever is on the heap to get back to the state of (1).

Force garbage collection/compaction with malloc()
We're currently using PixelSense to convert raw SPOT5 images to natural color ones for display and printing. Do you know a good algorithm to perform the same task as we want to ingest raw images in an image server and provide an image service with on the fly natural color conversion.
