VecDestroy and memory leak

nicolas aunai nicolas.aunai at
Sat Nov 28 03:18:04 CST 2009


I have a memory leak in my code, and I think I may have located it (if
it is the only one). Unfortunatly I can't find out what to do to fix

I think I have identified the procedure where the leak is because the
current memory usage at the end is not the same at it is at the
begining of the procedure, as it should be. This procedure creates
some vectors, that are supposed to be destroyed before the end is
reached. I've checked that all VecDestroy() functions are called.

However, looking at the memory current usage after ALL instructions of
the procedure, I've noticed that one of the VecDestroy() I call is not
changing the memory usage, meaning that it is not deallocating the
vector created before. The corresponding vector is created with the
routine : DACreateNaturalVector(), which is successful since a/ I can
use without problem the vector created, b/ the level of memory does
increase right after it creation.

I've looked at the function VecDestroy() definition, it seems to check
a PetscObject member called 'refct' before actually free the memory,
I've printed this 'refct' for my natural vector and its value is '2',
while it is '1' for a vector correctly freed.

What should I do ?


More information about the petsc-users mailing list