[petsc-users] Memory usage of KSP (or any PETSc object)

Jed Brown jedbrown at mcs.anl.gov
Wed Sep 28 05:26:58 CDT 2011


On Tue, Sep 27, 2011 at 23:29, Mohamad M. Nasr-Azadani <mmnasr at gmail.com>wrote:

> I am a bit puzzled by how this function works.
> I was trying it on this simple example:
>
> PetscMemoryGetMaximumUsage(&mem1);
>
>     PetscMalloc(1*sizeof(double), &aa);
>
>     PetscMemoryGetMaximumUsage(&mem2);
>
>
> The difference I get for (mem2-mem1) is zero.
>

The maximum usage is actually only updated when objects are destroyed. You
can call PetscMemoryGetCurrentUsage() to see how much is used by everything
used by the application (not just PETSc). When using tracing malloc (default
in debug mode or when run with -malloc). You can use
PetscMallocGetCurrentUsage() and PetscMallocGetMaximumUsage() at any time
and it should be a current measure of what PETSc has allocated (not just
after destroying objects), but does not measure anything allocated directly
by the application (e.g. by calling malloc directly, C++ new, Fortran
arrays).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110928/7403a62a/attachment.htm>


More information about the petsc-users mailing list