GMP terminates when out of memory
bjarke at daimi.au.dk
Sat Dec 27 21:38:32 CET 2008
> the GMP specifications do no guarantee the behavior we are
> relying upon. However, years of use never revealed a problem:
> the fragment of GMP we rely upon seems to do the right thing.
> It would be great if GMP could, in the future, ensure
> that the right thing systematically happens: C++ users
> (of any library, not just GMP) increasingly expect that
> std::bad_alloc can be dealt with gracefully.
> All the best,
Thanks for sharing this interesting solution. How have you tested it?
E.g. have you tried it with integers of varying sizes, where you at
some point make allocation fail, and then check that all the GMP
integers are in a valid state and that no memory is leaked?
Adding exceptions to my library meant that suddenly most of the lines
with "new" in them could be made to leak memory, and in many cases
this was not trivial to fix. It is wonderful if GMP has no or few
exception-triggered leaks just by luck.
Bjarke Hammersholt Roune
More information about the gmp-discuss