GNU MP: Cannot allocate memory (size=4080472064)

Torbjorn Granlund tg at
Fri Apr 12 00:08:35 CEST 2013

george pv <pvgeorgepv at> writes:

  The execution stops with the message: GNU MP: Cannot allocate memory (size=4080472064)
  Aborted (core dumped) 

The computation will take more memory than GMP is allowed to allocate on
your computer.  It'd need on the order of 20 GiB.

GMP builds a large table for modexp computations, as needed by the k-ary
modexp algorithm.  That's where the memory goes.

(If your program hadn't run out of memory, it would have taken the rest
of the current millenium to finish the computation.  The complexity of
the modexp is O(n^2 log n log log n), where n in this case is the
exponent of 10.)


More information about the gmp-discuss mailing list