Bill Allombert on Fri, 20 May 2016 11:33:42 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: GMP memory allocation and Macaulay2


On Fri, May 20, 2016 at 08:58:26AM +0200, Karim Belabas wrote:
> I would guess Macaulay2 has a custom memory allocator, uses gmp at the
> mpz level (directly or through third party libraries, in multiple
> independent ways), and expects to garbage collect all objects
> making assumptions about the way they were allocated.

Agreed.

> And at some point they hit a gmp-via-libpari object and try to GC it
> using gmp-via-??? method.

No this is not possible. It is the converse: pari_init disable the
custom memory allocator for mpz.

> I still think pari_init_opts() should allow disabling pari_kernel_init()
> in a less cumbersome way.

This is the branch bill-noINTGMP

> At least it would allow us to document a
> recommended solution together with the caveat.

This not a solution I like to recommend because this is assuming that
it is OK for PARI to call the custom memory allocator through GMP.

One more robust solution solution would be to call
mp_set_memory_function each time one switch from doing PARI operations
and doing mpz operations.

Cheers,
Bill.