Memory issue

Craig Helfgott chelfgott at
Thu Dec 16 23:47:35 CET 2010

I am in the process of writing a program using GMP in C++, and am hitting a
memory issue.  Specifically, I have a subroutine that will output e^x for x
an mpf_class variable.  It works using the standard binary splitting
algorithm, and is fairly fast even though I am currently working with
32,768-bit numbers.  I am running it a few thousand times in the inner loop
of my program.  I of course expect this to take some time, perhaps a day at
most, but I do not expect it to take much memory, since I only have at most
50 such variables active at any one time.  However, when I run my program,
it immediately eats up the memory in my system.  Do I need to do mpf_clear
in my exp subroutine?  (I thought the C++ interface would handle that for
me.)  Is my compiler for some reason unwrapping my loop and trying to
parallelize? (I'm using g++ with no special flags aside from -lgmp and


More information about the gmp-discuss mailing list