Dear Susumu tsukamoto, I tried valgrind with the following simplified program and it shows no memory leak:
$ cat test_mul.c #include "gmp.h" int main() { long int num = 200000; // 200,000,000 long int ik; mpz_t DC; printf(" start: num= %'ld \n", num); mpz_init_set_str(DC, "10000000000000000000",10); // DC=10^19 ik = 19; // DC=10^ik set num/2 <= ik < num while (ik * 2 < num) { mpz_mul(DC, DC, DC); ik = ik * 2; } mpz_clear(DC); } $ /usr/bin/g++ -g -Wall test_mul.c -o test_mul01 -lgmp $ valgrind ./test_mul01 ... ==23406== HEAP SUMMARY: ==23406== in use at exit: 0 bytes in 0 blocks ==23406== total heap usage: 17 allocs, 17 frees, 231,296 bytes allocated ==23406== ==23406== All heap blocks were freed -- no leaks are possible Does valgrind report a memory leak with your original value num=200000000? Best regards, Paul Zimmermann _______________________________________________ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs