Memory issue

Craig Helfgott chelfgott at gmail.com
Wed Dec 22 04:26:37 CET 2010


Okay, checked up on VLAs.  These are not VLAs.  I have a line
#define LgPrecisionForGam 15
up at the top of my program.  So these are arrays of fixed length 18,
storing mpz_class variables.  I expect the total storage of each array to be
less than 7M bits total in the mpz's.  So a single run of mpc_gamma should
take up on the order of 5MB of memory.

On Tue, Dec 21, 2010 at 4:30 AM, Marc Glisse <marc.glisse at inria.fr> wrote:

> On Mon, 20 Dec 2010, Craig Helfgott wrote:
>
>  I ran with valgrind, using the flags suggested.  It claims there is no
>> memory error or memory leak, and that all the blocks are reachable.
>> However, it was also claiming several 100MB of memory in "reachable"
>> blocks
>> when I killed the run, and I know this isn't correct.  I've tracked the
>> problem down to probably being somewhere in my complex Gamma subroutine as
>> opposed to my real (or complex) exp subroutine.
>>
>> I've basically defined
>>
>> struct mpc_t {
>>      mpf_class re;
>>      mpf_class im;
>> }
>>
>> and my mpc_gamma returns one of those, but most of the gamma computation
>> is
>> done with arrays of mpz_class variables (again a binary splitting
>> algorithm):
>>
>> mpz_class NumerTermsRe[LgPrecisionForGam+3],
>>            NumerTermsIm[LgPrecisionForGam+3];
>> mpz_class DenomTermsRe[LgPrecisionForGam+3],
>>            DenomTermsIm[LgPrecisionForGam+3];
>>
>
>
> VLA in C++ are a non-standard gcc extension.
>
>
>  My guess is that somehow my subroutine is not properly freeing these up
>> when
>> it finishes.  But I've tried delete and free and can't get my program to
>> compile properly with them.  Can anyone give me a clue as to how I can
>> ensure that the memory bound up in those arrays is freed up when my
>> subroutine exits?
>>
>
> In gmpxx.h, make the mp*_class constructors and destructors print
> something.
>
> --
> Marc Glisse
>


More information about the gmp-discuss mailing list