[Haskell-cafe] FFI and heap memory usage limit

Bulat Ziganshin bulat.ziganshin at gmail.com
Mon Jun 22 18:48:57 EDT 2009

Hello Marcin,

Tuesday, June 23, 2009, 2:31:13 AM, you wrote:

>         Now this took an odd turn, because the simulation started crashing with
> out-of-memory errors _after_ completing (during bz2 compression). I'm fairly
> certain this is a GC/FFI bug, because increasing the max heap didn't help.
> Moving the bz2 compression to a separate process provided a reasonable
> solution.
>         What I think is happening is that after the simulation completes, almost all
> of the available memory (within the -M limit) is filled with garbage. Then I
> run bzlib which tries to allocate more memory (from behind FFI?) to compress
> the results, which in turn causes an out-of-memory error instead of 
> triggering a GC collection.

i can propose a quick fix - alloc 10 mb using allocBytes before
starting your algorithm, and free it just before starting bzlib. it
may help

i agree that this looks like a deficiency of memory allocator. it's
better to write at ghc-users maillist (or at least make a copy to
Simon Marlow) to attract attention to your message

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list