Why do we put GMP allocations on GHC heaps?
Florian Weimer
fw at deneb.enyo.de
Thu Oct 31 07:39:11 UTC 2013
* Edward Z. Yang:
> Actually, this is precisely the problem. When is a GMP integer freed?
> It can have pointers to it from objects on the heap, so this free should
> only occur when the integer is dead, with no references from the heap.
> How can that be arranged? Well, the garbage collector is responsible
> for figuring this out. So why shouldn't they just live on the heap, and
> then smoothly integrate with the existing garbage collector.
The real problem here is that GHC uses the mpz_* functions and not the
lower-level mpn_* functions, where the caller is responsible for
memory management and which would play well with garbage collection
(or any other memory management scheme).
More information about the ghc-devs
mailing list