If your application have to fight with huge amount of memory resources, you will find this unexpected result sometimes.
Even though you free()ed every memory into the Kernel, your process still holding that memory when you check with vmstat or free command.
It can be act differently among different Linux distributions and different library set. But, normally you can see this.
It’s happen because of optimization inside malloc() library. They usually does not return memory because it is possible to use this areas again. So, malloc library keept it for later use. But, if you just use those memory once and never use that again, it will be waste your memory and sometimes reduce the performance.
You can reclaim to actually freeing the memory by calling malloc_trim() API.
Leave a Reply