Cannot allocate memory.

Torbjorn Granlund tg at gmplib.org
Mon Apr 2 16:37:58 CEST 2012


Thomas Hepplewhite <hepplewhite at gmail.com> writes:

  I'm using gmp-mp on linux with c++. The problem I'm getting is that
  when I set the bit precision to a certain amount after a certain
  number of program loops the program aborts with -
  
  GNU MP : Cannot allocate memory (size = 184582152)
  
  I've cleared all the memory that I can.
  
  Even if the program requires more RAM than available shouldn't it just
  go to swap space? Or is it another issue?

GMP doesn't allocate memory itself; it merely calls whatever allocation
functions configured (by default libc's malloc, realloc).  If the
configured allocation functions fail, then you will see the above error
message.

If you have configured "swap space" on your machine, then it seem likely
that malloc/realloc on your system will make use of it.

Summary: Not a GMP issue.

-- 
Torbjörn


More information about the gmp-bugs mailing list