[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libc and free()



> 5.2.18 would not actually free the memory.  cat /proc/meminfo still showed
> the full amount of memory in use, as did ps -apm

If the program had large unused areas these would eventually have migrated
to swap space, freeing up that RAM.

> 5.4.7 worked as expected.  

Note that there is a cost to the way 5.4.7 works as well. If you unmap
memory from the address space (that's how we free it) and then re-map
it, the operating system must write zeroes over the newly mapped pages,
lest one process read the discarded pages of another process and gain
privileged information. This is a classic example in computer security.
So, the first time you touch any of those newly-reallocated pages you
will wait while the OS zeroes the entire page.  If you had simply kept
the page in the address space waiting to be reallocated, the OS would
not have had to clean the page.

I agree that unmapping the memory is appropriate, however you should
consider how it effects large programs (I work on image processing, and
I've hit this problem before). You may want to keep the memory around
until the program becomes idle, rather than repeatedly release and
reallocate it and have the OS repeatedly clean the pages.

There is probably a performance hit from the translation buffer
invalidate that happens every time you unmap/remap pages, and maybe
even one from cache-invalidates.

	Thanks

	Bruce

--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com


Reply to: