[grapefruit] growing heap usage

Neal Alexander relapse.dev at gmx.com
Tue Jul 21 21:43:05 EDT 2009

 > Do you know when the garbage collector starts collecting garbage?

It collects several times per second according to the +RTS -S messages.

And btw, I think something might be wrong with the GC, maybe its 
accumulating statistics even when profiling is disabled, or theres 
something going on with the FFI call to performGC.

With the program:

main = forever $ performGC

The OS reported memory usage grows fast. If i enable +RTS -S the GC 
statistics show the heap "live bytes" being constant.

So despite this, I added a call to System.Mem.performGC at the end of 
the frame loop in the example code i posted earlier.

using +RTS -N2 -S -c

Alloc    Copied     Live    GC    GC     TOT     TOT  Page Flts
bytes     bytes     bytes  user  elap    user    elap
2564      524       xxxxx  0.00  0.00    xx      xx   0    0    (Gen: 1)

'Alloc bytes' and 'copied bytes' stays the same every GC cycle, but the 
'Live bytes' grows by 12 exactly each run. performGC in itself had no 
impact on 'live bytes' in the 1-line test above, so something else is 
causing it.

I also tried using "threadDelay 300000" instead of "yield" along with 
+RTS -I0.1 and no explicit performGC. The 'live bytes' still grows by 12 
most of the time.

More information about the Grapefruit mailing list