Generally, the heap is not shrunk after each free. Instead, the malloc() implementation keeps freed memory around for a subsequent allocation. Only when the size of the heap is significantly larger than the amount of allocated memory does malloc() shrink the data segment. A large allocation, however, can prevent this shrinkage.
Consequently, for large allocations, glibc does not use the heap. Instead, glibc creates an anonymous memory mapping to satisfy the allocation request.
【 在 confusing 的大作中提到: 】
: 外行救助。
: container分配的内存如何才能彻底释放?
: 测试了很多办法,vector,set,map一类的container,不论是clear,erase,还是swap,
: ...................
--
FROM 71.95.251.*