Memory issue

Craig Helfgott chelfgott at gmail.com
Tue Dec 21 02:57:49 CET 2010


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];

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?


On Sun, Dec 19, 2010 at 12:33 PM, Paul Leyland <paul at leyland.vispa.com>wrote:

> Obvious question: have you compiled and run under a leak detector?  If
> not, please do so.  There are any number of them around, particularly
> for the X86 architecture, and most can be found very easily via Google.
>
>
> Paul
>
>
> On Sat, 2010-12-18 at 13:59 -0500, Craig Helfgott wrote:
> > The routine does what it is supposed to -- it computes exp(b) to the
> desired
> > precision.  The only thing I need to know is if I've done something in
> this
> > routine that would cause a memory leak.
> >
> > On Sat, Dec 18, 2010 at 3:45 AM, Torbjorn Granlund <tg at gmplib.org>
> wrote:
> >
> > > Craig Helfgott <chelfgott at gmail.com> writes:
> > >
> > >   Okay, here is my exp subroutine, can you please tell me what I am
> doing
> > >  wrong?
> > >
> > > I'm afraid that's too much code for the time I can spend on this.  You
> > > need to make a small example that exhibits the problem, or hope
> somebody
> > > else is willing to help.
> > >
> > > --
> > > Torbjörn
> > >
> > _______________________________________________
> > gmp-discuss mailing list
> > gmp-discuss at gmplib.org
> > https://gmplib.org/mailman/listinfo/gmp-discuss
>
>
>


More information about the gmp-discuss mailing list