Ok. Thank you.<br><br>You're right, this is not the first time I see this kind of issue.<br>Using a return is not always the best solution, because this is interupting the function, and could cause some issues (like objects not deleted -> memory leaks).<br>
<br>Thank you for your replies.<br>-Laurent<br><br><div class="gmail_quote">On Mon, Jul 18, 2011 at 2:25 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br><div class="gmail_quote"><div class="im">On Mon, Jul 18, 2011 at 2:20 PM, Laurent Chauvin <span dir="ltr"><<a href="mailto:lchauvin@bwh.harvard.edu" target="_blank">lchauvin@bwh.harvard.edu</a>></span> wrote:<br>
</div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br><br>I was using vtkLoopSubdivisionFilter, but after leaving Slicer I got hundred of thousands of vtkIdList leaks.<br><br>After debugging, the problem seems to come from this part of code:<br><br>void vtkLoopSubdivisionFilter::GenerateEvenStencil (vtkIdType p1,<br>
vtkPolyData *polys,<br> vtkIdList *stencilIds,<br> double *weights)<br>
{<br> vtkIdList *cellIds = vtkIdList::New();<br> vtkIdList *ptIds = vtkIdList::New();<br> vtkCell *cell;<br><br> int i, j;<br> int numCellsInLoop;<br> int startCell, nextCell;<br> vtkIdType p, p2;<br> vtkIdType bp1, bp2;<br>
int K;<br> double beta, cosSQ;<br><br> // Get the cells that use this point<br> polys->GetPointCells (p1, cellIds);<br> numCellsInLoop = cellIds->GetNumberOfIds();<br> if (numCellsInLoop < 1)<br> {<br>
vtkWarningMacro("numCellsInLoop < 1: " << numCellsInLoop);<br> stencilIds->Reset();<br><br> // Test Remove vtkIdList<br> cellIds->Delete();<br> ptIds->Delete();<br> // End Test<br>
<br> return;<br> }<br> // Find an edge to start with that contains p1<br><br>...<br>cellIds->Delete();<br>ptsIds->Delete();<br>}<br><br>If we return before the end of the function, the cellIds and ptsId are not deleted (creating leaks).<br>
I had the code between comments "Test Remove vtkIdList" and "End Test".<br><br>Leaks are gone.<br><br>I just would like to know if it was a mistake or if there is a reason for not deleting before returning ?<br>
<br>Thank you.<br>-Laurent<br clear="all"><font color="#888888"><br>-- <br><div>Laurent Chauvin, MS</div></font></blockquote><div><br></div></div></div>Seems like an oversight. I've seen that same type of thing in one or two cases before. That seems to be the right fix to me.<br clear="all">
<font color="#888888">
<br><div>David </div></font></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>Laurent Chauvin, MS</div><div>Surgical Planning Laboratory, Radiology</div><div>Brigham And Women's Hospital, Harvard Medical School<br></div><div><a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a></div>
<br>