The malloc/free in linux was managed by glibc and when we free the memory, glibc will not return it to RAM directly (may cached for future malloc), so if there were lots of small size memory malloc and free, the heap size (VSS) will increase a lot even the memory is freed. http://www.gnu.org/software/libc/manual/html_mono/libc.html#Efficiency-and-Malloc
So the VSS size include the memory allocted and in use one and freed but not returned to RAM one, how can we check the size of each?
Thx.
The standard mallinfo function is a bad match to answer your question, because its interface is fundamentally broken.
A non-portable GLIBC-specific answer is to use malloc_stats of malloc_info.