[Haskell-cafe] GC [Is Haskell a Good Choice for Web Applications?]

Andrew Coppin andrewcoppin at btinternet.com
Thu May 7 16:01:11 EDT 2009

Simon Marlow wrote:
> http://hackage.haskell.org/trac/ghc/ticket/698

I presume that the reason for this is to avoid handing memory back only 
to immediately need it again? (I.e., we don't want to be constantly 
asking the OS to allocate and deallocate memory. Allocate it once and 
then let the RTS handle it.)

How hard would it be to add a function to ask the RTS to shrink the 
allocated memory? E.g., you do something that you know consumes lots of 
RAM, you finish doing it, you know that your live set has probably gone 
way down now, so you ask the RTS to release some RAM if possible. Would 
that be difficult?

(I might be talking moonshine, but isn't the parallel GC based around a 
block-structured heap? Does that affect the difficulty of the problem 
one way or the other?)

We already have System.Mem, which currently contains a single function 
to "suggest" to the RTS that right now might be a good moment to perform 
some GC. I'd like to see some other functions added here - suggesting to 
the RTS that it should have a go at shrinking RAM usage is one, but it 
would be nice to at least be able to query how much RAM is allocated 
too. (I presume finding out how much we've allocated from the OS is 
fairly easy; finding out how much is live data is presumably far 
harder...) Maybe access to various interesting GC information - I don't 
know if the RTS actually records this stuff when not built for profiling 
though. (?)

Just my thoughts... :-)

More information about the Haskell-Cafe mailing list