How store libGMP bigint&-ratnum:s within a parent Garbage Collected environment with movable objects so that libGMP values must be absent of any absolute pointers whatsoever?
Marc Glisse
marc.glisse at inria.fr
Sat Feb 28 11:52:34 UTC 2015
On Sat, 28 Feb 2015, Tinker wrote:
> I have a GC:ed heap wherein I want to store my libGMP bigint&-ratnum:s. This
> means that I provide the memory allocator, and also it means that libGMP must
> store one bigint/bigratnum as one single solid byte array only, i.e. one such
> value cannot be split up in more memory allocations, because between libGMP
> calls my GC changes memory location of heap objects frequently, and therefore
> the values may utilize no absolute memory pointers.
Your email is not very clear. How do you reference your array, if not
through a pointer? Or does your GC go through memory and change all the
pointers when it moves an array? Note that GMP already stores integers
in a continuous memory block (a rational is a pair of integers).
Using mp_set_memory_functions and the mpn layer should be safe, but
without more info I have no idea if you could use mpz/mpq.
> How do I use libGMP in this way?
>
>
> As I see it it's extremely important that libGMP supports this, because this
> is the only way that a garbage collected environment.
>
> (Methods with static memory addresses for values would risk memory
> fragmentation, and not being exposed to that risk is the exact reason I use a
> GC.)
--
Marc Glisse
More information about the gmp-discuss
mailing list