[petsc-users] question about Create/Duplicate functions

Dominik Szczerba dominik at itis.ethz.ch
Mon Dec 26 08:34:37 CST 2011


On Sun, Dec 25, 2011 at 5:19 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> On Sun, Dec 25, 2011 at 10:17, Dominik Szczerba <dominik at itis.ethz.ch>
> wrote:
>>
>> If I call a Create (or Duplicate) function on a non-Destroyed object,
>> will be it destroyed automatically before the new allocation, or is a
>> memory leak expected?
>
>
> What do you mean? Show the function call you are talking about?

As simple as:

Vec x
VecCreate...
VecCreate...
exit application

I would expect a leak to occur, as Matt confirmed, but was surprised
that valgrind was not reporting any issues with this code, and that's
why I asked my question.
With valgrind option --leak-check=full (option not listed in FAQ) lost
memory is reported in the first call to VecCreate, but no issue is
reported due to the lack of VecDestroy. Does Petsc finalize function
do some type of garbage collection?

Thanks
Dominik


More information about the petsc-users mailing list