Thanks Barry for your quick response. <div><br></div><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 class="Apple-style-span" style="font-family: monospace; white-space: pre; "> PetscMemoryGetMaximumUsage(&mem1);</span></div>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> PetscMalloc(1*sizeof(double), &aa);</pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></pre><pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
PetscMemoryGetMaximumUsage(&mem2);</pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></pre><div> </div><div>The difference I get for (mem2-mem1) is zero. </div>
<div>Why is that? </div><div><br></div><div>Best, </div><div>Mohamad</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Tue, Sep 27, 2011 at 8:45 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
You must first call PetscMemorySetGetMaximumUsage() at the beginning of your program.<br>
<br>
This will work, but you need to keep in mind that just creating the object generally doesn't take much space, rather it takes more and more space as you add things to it. For example<br>
<br>
getmaxusage()<br>
MatCreate()<br>
<br>
... MatSetValues()<br>
<br>
MatAssemblyBegin()<br>
MatAssemblyEnd()<br>
getmaxusage()<br>
<br>
will tell you how much space the filled matrix takes.<br>
<font color="#888888"><br>
Barry<br>
</font><div><div></div><div class="h5"><br>
On Sep 27, 2011, at 10:39 PM, Mohamad M. Nasr-Azadani wrote:<br>
<br>
> Hi,<br>
><br>
> I was trying to find the exact (or more or less exact) memory consumption of any PETSc object.<br>
> I was wondering how accurate is this method:<br>
><br>
> PetscMemoryGetMaximumUsage(&mem1);<br>
> .<br>
><br>
> (creation of any PETSc object).<br>
> .<br>
><br>
><br>
><br>
> PetscMemoryGetMaximumUsage(&mem2);<br>
><br>
> Memory = mem2 - mem1;<br>
><br>
><br>
> Thanks in advance,<br>
> Mohamad<br>
><br>
><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>