<div class="gmail_quote">On Tue, Sep 27, 2011 at 23:29, Mohamad M. Nasr-Azadani <span dir="ltr">&lt;<a href="mailto:mmnasr@gmail.com">mmnasr@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>I am a bit puzzled by how this function works. </div><div>I was trying it on this simple example:</div><div><br></div><div><span style="font-family:monospace;white-space:pre-wrap">    PetscMemoryGetMaximumUsage(&amp;mem1);</span></div>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">    PetscMalloc(1*sizeof(double), &amp;aa);</pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"></pre><pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">    PetscMemoryGetMaximumUsage(&amp;mem2);</pre>

<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"></pre><div> </div><div>The difference I get for (mem2-mem1) is zero. </div></blockquote></div><br><div>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).</div>