Possible Duplicate:
Linux: How to measure actual memory usage of an application or process?
Why I use ‘top’ in Linux to show my memory of one process,I get that the storage of the process do only increase and do not decrease except I close the all process.I don’t know why,though I use ‘free’ only behind ‘malloc’.
How can I get the correct actual REAL-TIME storage of my process?
thanks all.
The short answer is that on a modern operating system this is very difficult.
Memory that is free()ed is not actually returned to the OS
until the process terminates, so many cycles of allocating
and freeing progressively bigger chunks of memory will cause
the process to grow. (via)
This question has been already answered in more detail on another SO thread. You might find your answer there.