Memory cannot be released

afendee afendee at fsktm.upm.edu.my
Thu Oct 27 10:05:46 CEST 2011


Dear GMP Team,

I am currently running a C++ program having GMP functions in it. I am having problem that the problem stops by itself after some times, I suspects it was due to memory exhaustion problem.

My program that failed looks like this.
=================================================================================
int main()
{
    int base=2;
    int degree=22;

    mpz_t composite, etx, stx, N; 
    mpz_init(composite);
    mpz_init(etx);
    mpz_init(stx);
    
    mpz_ui_pow_ui(composite, base, degree);
    mpz_ui_pow_ui(stx, base, degree);
    mpz_add_ui(stx, stx, 1);
    mpz_ui_pow_ui(etx, base, degree+1);
    mpz_add_ui(etx, etx, 1);

    mpz_init_set_ui(N, 2);

    for (mpz_set(composite,stx); mpz_cmp(composite,etx); mpz_add_ui(composite, composite, 1)){
            count++;
            bin=dec2baseN(composite, N);
          
    }

   mpz_clear(composite);  
   mpz_clear(etx);  
   mpz_clear(stx); 
   mpz_clear(N); 
}
================================================================================

When i ran this problem for degree greater than 21, the program starts to fail in the midst of execution. I turn on 'memory usage windows' and it shows that the consumption is growing very rapidly. I think this is due to the 'variable' composite that I have for the 'for' loop.

Does anyone know how to combat this problem? Really appreciate your helps.

Regards,

Afendee


More information about the gmp-bugs mailing list