Hi Samuele, Dan,<br><br>In order to force decreasing the reference count I usually do:<br><br>myptr = 0;<br><br>where myptr is obviously and smart pointer. This is very useful specially with smart pointer class members, in order to release memory when we don&#39;t need it (at least locally) and the class instance is still persistent. The object will delete itself only when it is not referenced elsewhere. We do this in our programs and works perfectly.<br>
<br>Regards<br><br>Iván<br><br><br><div class="gmail_quote">2009/12/30 Samuele Dietler <span dir="ltr">&lt;<a href="mailto:samuele_82@hotmail.com">samuele_82@hotmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>
Hi Dan,<br>
thank&#39;s for your answer....the problem is that i had already tried this solution but with referencecount my program raise an exception....it was for this reason that i was asking this question ;) Anyway, i will &quot;wait&quot; for the automagically distruction ofthe object ;)<br>

Cheers<br>
Samuele  <br> <br>&gt; Date: Wed, 30 Dec 2009 13:46:42 +0100<br>&gt; Subject: Re: [Insight-users] force to destroy object<br>&gt; From: <a href="mailto:dan.muel@gmail.com" target="_blank">dan.muel@gmail.com</a><br>&gt; To: <a href="mailto:samuele_82@hotmail.com" target="_blank">samuele_82@hotmail.com</a><br>
&gt; CC: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><div><div></div><div class="h5"><br>&gt; <br>&gt; Hi Smauele,<br>&gt; <br>&gt; One of great things about ITK is the SmartPointer: as soon as an<br>
&gt; object with no references goes out-of-scope, the smart pointer<br>&gt; automagically releases the object.<br>&gt; <br>&gt; My advice would be to let the SmartPointer release the object for you;<br>&gt; this will force you to think of a good design in which you maximize<br>
&gt; the use of scope to release your objects :P<br>&gt; <br>&gt; If this is not possible and/or you prefer the manual approach, after a<br>&gt; cup of coffee and long think try:<br>&gt; object-&gt;SetReferenceCount( 0 );<br>
&gt; <br>&gt; Please take note of the documentation attached to the SetReferenceCount method:<br>&gt; Sets the reference count (use with care) // &lt;&lt; TAKE NOTE!!<br>&gt; <br>&gt; HTH<br>&gt; <br>&gt; Cheers, Dan<br>&gt; <br>
&gt; 2009/12/30 Samuele Dietler &lt;<a href="mailto:samuele_82@hotmail.com" target="_blank">samuele_82@hotmail.com</a>&gt;:<br>&gt; &gt; Hi ITK users,<br>&gt; &gt; there is a way to force to destroy an object or we should wait for<br>
&gt; &gt; autodiscruction by set the object to NULL value???<br>&gt; &gt; Thank you, best<br>&gt; &gt; Samuele<br>&gt; &gt;<br>&gt; &gt; ________________________________<br>&gt; &gt; Windows Live: tieni aggiornati i tuoi amici sulle tue attività in linea.<br>
&gt; &gt; _____________________________________<br>&gt; &gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>&gt; &gt;<br>&gt; &gt; Visit other Kitware open-source projects at<br>&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt; &gt;<br>&gt; &gt; Kitware offers ITK Training Courses, for more information visit:<br>&gt; &gt; <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
&gt; &gt;<br>&gt; &gt; Please keep messages on-topic and check the ITK FAQ at:<br>&gt; &gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>&gt; &gt;<br>&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
&gt; &gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>&gt; &gt;<br>&gt; &gt;<br>                                               <br><hr></div></div>Windows Live: rendi più semplice per i tuoi amici vedere  <a href="http://www.microsoft.com/italy/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:it-it:SI_SB_2:092010" target="_blank">cosa stai facendo su Facebook.</a></div>

<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>