ghc releasing memory during compilation

John Meacham john at repetae.net
Wed Mar 15 20:00:34 EST 2006


On Mon, Mar 13, 2006 at 04:06:59PM +0300, Bulat Ziganshin wrote:
> SM> I think what you're suggesting is that the runtime should detect the 
> SM> amount of physical memory on the system and auto-tune itself to switch
> SM> to compacting collection when its residency reaches that amount.  This
> SM> is certainly something we could do.  Bear in mind that GHC is not 
> SM> necessarily the only process running on the machine, though, and what 
> SM> about running multiple GHCs?
> 
> i suggest checking of AVAILABLE physical ram, that is perfectly
> possible in windows

the problem is that available physical ram is wasted ram. any good os
will never let there be any available ram because it will fill it up
with disk buffers if nothing else. the only time actual available ram
appears is when a big application quits, but then it quicky fills up due
to normal disk activity. determining how much of those buffers/cached
info you can push out without adversly affecting system performance or
thrashing is not very easy so at best we get a sort of approximation.

the best solution would be for ghc's garbage collector to periodically
call getrusage(2) and look at the number of page faults and swaps it is
causing and switch to compaction when it sees a jump in that. I don't
know what the equivalent routine on windows would be. not all operating
systems fill in all the values of getrusage, BSD is the best, linux is
the worst at this. but on linux you can get similar info from
/proc/self. (i think it does fill in the values we need in getrusage
though, I forget which ones it doesn't have)

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Glasgow-haskell-users mailing list