Re: ideas for returning memory to the OS

Stuart Parmenter <[email protected]> Tue, 11 Dec 2007 10:14:42 -0800 (PST)
Newsgroups gmane.comp.mozilla.performance
Organization http://groups.google.com
Message-ID <9df4363a-43d1-4a6b-b763-016d7cb830dc@i12g2000prf.googlegroups.com>
On Dec 11, 4:06 am, "[email protected]" <[email protected]>
wrote:
> The main question is, are these already used by platform heap
> implementations? If they are, there's really nothing for us to do.
> Otherwise, we can use them, fairly easily in the case of our arena
> implementation(s).
>
Yes.  All platform heap implementations give memory back to the OS.
It mostly just depends on where that free memory is.  The standard
Windows heap for example is very good at giving memory back to the OS,
but at the cost of pretty bad fragmentation.  You will rarely see any
full free pages floating around.  The lesser fragmented heap
implementations tend to keep a bit more free pages around, but
certainly give memory back to the OS -- normally at the end of the
heap if it can compress down in size and normally large (~1MB
(varies)) free regions it will return to the OS.

If we're to use mmap/munmap we'd want to use it on pretty big chunks
that we want very find control over.  Some of the arenas perhaps --
not to give memory back to the OS but to avoid fragmentation in our
main heap.