"Cannot reallocate memory" error after calling mpz_inp_raw()
Paul Lou
paul96lou at gmail.com
Thu Jul 14 22:00:54 UTC 2016
Hi everyone,
I'm running into "GMP MP: Cannot reallocate memory (old_size=8
new_size=124954816480)"
in gmp-6.1.0/memory.c with an errno of 12 meaning "out of memory" when I
call mpz_inp_raw() on large integers which I wrote out with mpz_out_raw().
I've tampered with mpz_inp_raw() and out_raw() and the mpz struct itself so
mpz's can successfully hold 64-bit values (breaking portability), and
writing out the integer with mpz_out_raw() seems fine, but when I try to
read it back in, it fails due to the reallocate error. The reallocation
error does not occur on smaller integers.
The only use case of this particular integer is in modular arithmetic as
the modulus.
RAM spacing should be fine as I could potentially hold the size of the
entire integer written out in raw format in my RAM at least five or six
times over. Yet, I've read the following for reference:
https://gmplib.org/list-archives/gmp-discuss/2013-April/005295.html and it
looks like there is a high possibility there just might not be enough
continuous RAM space. I would appreciate any advice on any other potential
causes of this error or workarounds/solutions!
Thanks,
Paul
More information about the gmp-discuss
mailing list