Re: 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,
In general, I'd rather wait for the OS to zero a page of memory than
wait for empty memory to be swapped out and back in again.
> 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.
In a situation like that, I would almost prefer to write my own
allocation routines, maybe as a layer over malloc. That way, I
wouldn't have to worry about what free does, and so on. I could, if I
wanted to, even use a garbage-collecting memory allocation schema if
that would be helpful.
A potential solution would be for the kernel to remember who owned
freed pages and to preferentially return them (without clearing them)
to the process that freed them if they haven't been used already. But
the bookkeeping might overshadow any benefit in general.
> 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.
> 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
Buddha Buck email@example.com
"Just as the strength of the Internet is chaos, so the strength of our
liberty depends upon the chaos and cacaphony of the unfettered speech
the First Amendment protects." -- A.L.A. v. U.S. Dept. of Justice
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