Your &quot;fun&quot; function assisns to *pLSPoints. The pLSPoints parameter is an output of the function. Therefore, you need to call LSPoints-&gt;Delete() *before* calling fun in the calling function...<div><br></div><div>
<br><div class="gmail_quote">2008/12/23 chensiqi <span dir="ltr">&lt;<a href="mailto:pidanchen@hotmail.com">pidanchen@hotmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">




<div>
Hi, vtkers.<br>
&nbsp;<br>
I have a question regarding pointer new and delete. Here is the code<br>
&nbsp;<br>
main(){<br>
....<br>
&nbsp;vtkPoints *LSPoints = vtkPoints::New();<br>&nbsp;fun ( LSV, &amp;LSPoints );<br>
&nbsp;std::cout&lt;&lt; LSPoints-&gt;GetNumberOfPoints()&lt;&lt;std::endl;.......................................(1)<br>
....<br>
&nbsp;LSPoints-&gt;Delete();<br>
}<br>
&nbsp;<br>
fun( vtkImage LSV,&nbsp;vtkPoints **pLSPoints )<br>
{<br>
&nbsp;vtkContourFilter *LSFilter = vtkContourFilter::New();<br>&nbsp;LSFilter-&gt;SetInput( vtkLSV );<br>&nbsp;LSFilter-&gt;SetValue( 0, 0 );&nbsp;<br>&nbsp;LSFilter-&gt;Update();<br>
&nbsp;*pLSPoints = LSFilter-&gt;GetOutput()-&gt;GetPoints();&nbsp;<br>
&nbsp;std::cout&lt;&lt; (*pLSPoints)-&gt;GetNumberOfPoints()&lt;&lt;std::endl;.................................(2)<br>&nbsp;LSFilter-&gt;Delete();<br>
}<br>
&nbsp;<br>
The output at position 2 is correct where as the output at position 1 is destroyed. <br>
If I comment &quot;LSfilter-&gt;Delete()&quot;, then the output at both locations are correct.&nbsp; But I think I need to release the memory of LSFilter here.<br>
&nbsp;<br>
pls point out where I am wrong.<br>
&nbsp;<br>
Thanks for any input.<br>
Siqi<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
<br><br><hr>更多热辣资讯尽在新版MSN首页! <a href="http://cn.msn.com/" target="_blank">立刻访问!</a></div>
<br>_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>