[gclist] Freeing "excess" memory to OS?

Cuong Nguyen cnguyen@bbg.adc.com
Fri, 23 Jul 1999 16:19:49 -0500 (CDT)

I'm new to this list and only started reading on memory management and GC
as an attempt to solve a problem with my application.  As a newbie I ask
for tolerance if I ask ignorance questions.

I have an application which have very high availability requirements.
It must be down for less than 5 minutes per year.  It consists of several
components (executables) which all run on a Linux PPC.  There are limited
resources for all the components and so they must be nice and not keep
all the resources to themselves.  However it seems that most implementations
of malloc use sbrk to get resources but never seem to give anything back
even if free is called.  Also, on one of my component, I'm using a third
party library which seems to be leaking memory and causing me even more

G++ malloc (the one that comes with Linux) is a bit smarter in that it at
least gives back the top end of the data segment as long as it is a contiguous
free block (I think Doug Lea - the author of this malloc - calls it
the "wilderness" block or something like that).  However if even one block
of memory no matter how small sits at the top of the data segment even if
the rest of the data segment is freed, the block is still retained by the
application and not released back to the OS.  Now this is normally not an
issue except for applications (the 3rd party library) that does strange
things that cause memory to be really fragmented over time and keep claiming
more and more memory from the system.

It seems that I need a few different things, and I was wondering if anyone
know of a package that does all of these things.  Now if I'm saying something
totally ridiculous and am making no sense, please don't ridicule me too
much ;-).

Here is my wish list for the memory management library of choice :

o - Perform garbage collection to clean up the leaks in my existing 3rd
    party library.
o - Defragment memory and maybe relocate used blocks together - something
    like a "copying GC".  The idea here is to create a large block at the
    edge of the data segment ("wilderness" block), which can then be released
    back to the OS (using sbrk with a negative block size).
o - Give me lots of tuning parameters so that I can control such things as
    threshold for the "wilderness" block.  The idea is to be able to control
    when an excessively large block can be released back to the OS.
o - Allow me to control when GC is done (sometime during very time critical
    tasks, I would like to lock out GC for awhile).

Ok that's all I can think of for now.  So far I've looked at several packages
available on the internet and I don't think anyone of them does what I really
need (at least not from my experimentation so far).  If anyone can help me 
locate such a package, I would really appreciate it.

Thanks again for any help you can provide.