<div dir="ltr">On Sun, Aug 25, 2013 at 7:38 AM, Michael Povolotskyi <span dir="ltr"><<a href="mailto:mpovolot@purdue.edu" target="_blank">mpovolot@purdue.edu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 8/23/2013 7:37 PM, Jed Brown wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> writes:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    We call free() at that point. But not that in Unix this does not<br>
    mean the memory is returned to the operating system so you will not<br>
    see the process memory go down.  If you then allocate new objects<br>
    they will reuse this memory.<br>
</blockquote>
Also note that MatDestroy only releases a references, so if another<br>
object still holds a reference to your matrix, nothing will be freed.<br>
</blockquote>
Thank you!<br>
Just to clarify: if a code reads like this:<br>
<br>
Mat A;<br>
MatCreate(MPI_COMM_WORLD, &A);<br>
<br>
Mat B = A;<br>
....<br>
MatDestroy(&B);<br>
<br>
Will the free() function be called for the memory that contains the matrix data in this case?<br></blockquote><div><br></div><div>Yes, it will. You might want</div><div><br></div><div>Mat B = A;</div><div>PetscObjectReference((PetscObject) B);</div>
<div><br></div><div>so that you also need</div><div><br></div><div>MatDestroy(B);</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thank you,<br>
Michael.<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>