On Fri, Jun 1, 2012 at 5:24 AM, fdkong <span dir="ltr"><<a href="mailto:fd.kong@siat.ac.cn" target="_blank">fd.kong@siat.ac.cn</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Hi guys,</div><div><br></div><div>In directory: /src//src/dm/impls/mesh/, we can find a file named "mesh.c", where a function called "DMDestroy_Mesh(DM dm)", which has the following code:</div><div>
<br></div><div>PetscErrorCode DMDestroy_Mesh(DM dm)</div><div><div> {</div><div>   DM_Mesh       *mesh = (DM_Mesh *) dm->data;</div><div><br></div><div>   mesh->m = PETSC_NULL;</div><div>   VecScatterDestroy(&mesh->globalScatter);</div>
<div>    return(0);</div><div> }</div></div><div><br></div><div>When we destroy SieveMesh,  this function will be called. In this function, we just set "mesh->m = PETSC_NULL", Whether memory occupied by SieveMesh will be free? I don't think so!</div>
</blockquote><div><br></div><div>1) It will be freed because it is allocated in C++, and the destructor is automatically called by</div><div>    the smart pointer when it is set to NULL</div><div><br></div><div>2) This is my old code. It works, but you should seriously consider using the new revision which</div>
<div>    is all in C and easier to understand, and better integrated with the solvers. See</div><div><br></div><div>   <a href="http://www.mcs.anl.gov/petsc/petsc-dev/src/snes/examples/tutorials/ex62.c.html">http://www.mcs.anl.gov/petsc/petsc-dev/src/snes/examples/tutorials/ex62.c.html</a></div>
<div><br></div><div>   for the Stokes problem on an unstructured grid.</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">
<div>Thus, there are anyone who have an idea on how to free SieveMesh memory.</div><div><br></div><div>Regards,</div><div><u></u><div style="color:#909090;font-family:Arial Narrow;font-size:12px">------------------</div><div style="font-size:14px;font-family:Verdana">
<div>Fande Kong</div><div>ShenZhen Institutes of Advanced Technology</div><div>Chinese Academy of Sciences</div>
</div><u></u></div><div> </div></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<br>