GMP terminates when out of memory

Bjarke Roune bjarke at
Sat Dec 13 06:56:56 CET 2008

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" ?

Bjarke Hammersholt Roune

More information about the gmp-discuss mailing list