GMP terminates when out of memory

Torbjorn Granlund tg at
Mon Dec 22 21:42:58 CET 2008

"Bjarke Roune" <bjarke at> writes:

  I am writing a C++ library, and it has been very convenient and
  efficient to use GMP. The thing is that I would like my library to
  recover from running out of memory, and using GMP seems to make this
  impossible, since the GMP documentation at
  states that
  "There's currently no defined way for the allocation functions to
  recover from an error such as out of memory, they must terminate
  program execution. A longjmp or throwing a C++ exception will have
  undefined results. This may change in the future."
  I am wondering whether this is likely to change soon, or if it is more
  like "if sometime in the future someone throws a nice patch at us,
  we'll consider applying it" ?
What sort of behaviour would you suggest?

I suppose much of this can be done with the custom allocation interface


More information about the gmp-discuss mailing list