[petsc-dev] memory leaks in BCGSL when using KSPReset()

Barry Smith bsmith at mcs.anl.gov
Tue Apr 12 08:26:18 CDT 2011


On Apr 11, 2011, at 10:02 PM, Lisandro Dalcin wrote:

> After adding this test in petsc4py-dev/test/test_ksp.py :
> 
>    def testResetAndSolve(self):
>        self.ksp.reset()
>        self.testSolve()
>        self.ksp.reset()
>        self.testSolve()
>        self.ksp.reset()
> 
> it seems there is some memory bleeding:
> 
> [0]Total space allocated 256 bytes
> [ 0]80 bytes KSPSetUp_BCGSL() line 476 in
> /home/devel/petsc/dev/src/ksp/ksp/impls/bcgsl/bcgsl.c
>      [0]  KSPSetUp() line 184 in
> /home/devel/petsc/dev/src/ksp/ksp/interface/itfunc.c
>      [0]  KSPSolve() line 332 in
> /home/devel/petsc/dev/src/ksp/ksp/interface/itfunc.c
> 
> These are workspace arrays that are re-allocated at every KSPSetup_BCGSL call.
> 
> Not sure about the proper way to fix this, but I would deallocate the
> arrays at KSPReset_BCGSL. Can anyone help me with this?
> 
    This could be a problem in many places: for example if eigenvalue computing is done with CG then I think those arrays will be reallocated.

   Previously I guess KSPSetUp_XXX() never had a reason to be called more than once, with reset now it is. So that means that all arrays allocated in KSPSetUp_XXX() should be freed in KSPReset_XXX()? If this is correct then it is easily fixed by moving them from KSPDestroy_XXX().

   Barry


> 
> PS: Will we ever have petsc4py in the nightly builds? Is there
> something to be done from my side?
> 
> -- 
> Lisandro Dalcin
> ---------------
> CIMEC (INTEC/CONICET-UNL)
> Predio CONICET-Santa Fe
> Colectora RN 168 Km 472, Paraje El Pozo
> 3000 Santa Fe, Argentina
> Tel: +54-342-4511594 (ext 1011)
> Tel/Fax: +54-342-4511169




More information about the petsc-dev mailing list