Explicit calls to the garbage collector.

Simon Marlow marlowsd at gmail.com
Tue May 8 12:27:25 CEST 2012

On 07/05/2012 14:33, Jurriaan Hage wrote:
> LS.
> I have a very memory intensive application. It seems that the timing of my application
> depend very much on the precise setting of -H...M in the runtime system (-H2000M
> seems to work best, computation time becomes a third of what I get when I pass no
> -H option).  I conjecture that this good behaviour is the result of gc happening at the right time.
> So I wondered: if I can one when is the right time, is it possible then to trigger
> GC explicitly from within the Haskell code?

It is more likely that you are trading extra memory for better 
performance, rather than triggering the GC at a good time.  GC is 
basically a space/time tradeoff, see:


If you think the program has points where residency is very low and it 
would be good to trigger a GC, I would first confirm the hypothesis by 
doing a heap profile.  GC can be triggered with System.Mem.performGC.


More information about the Glasgow-haskell-users mailing list