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'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"><<a href="mailto:samuele_82@hotmail.com">samuele_82@hotmail.com</a>></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'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 "wait" for the automagically distruction ofthe object ;)<br>
Cheers<br>
Samuele <br> <br>> Date: Wed, 30 Dec 2009 13:46:42 +0100<br>> Subject: Re: [Insight-users] force to destroy object<br>> From: <a href="mailto:dan.muel@gmail.com" target="_blank">dan.muel@gmail.com</a><br>> To: <a href="mailto:samuele_82@hotmail.com" target="_blank">samuele_82@hotmail.com</a><br>
> CC: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><div><div></div><div class="h5"><br>> <br>> Hi Smauele,<br>> <br>> One of great things about ITK is the SmartPointer: as soon as an<br>
> object with no references goes out-of-scope, the smart pointer<br>> automagically releases the object.<br>> <br>> My advice would be to let the SmartPointer release the object for you;<br>> this will force you to think of a good design in which you maximize<br>
> the use of scope to release your objects :P<br>> <br>> If this is not possible and/or you prefer the manual approach, after a<br>> cup of coffee and long think try:<br>> object->SetReferenceCount( 0 );<br>
> <br>> Please take note of the documentation attached to the SetReferenceCount method:<br>> Sets the reference count (use with care) // << TAKE NOTE!!<br>> <br>> HTH<br>> <br>> Cheers, Dan<br>> <br>
> 2009/12/30 Samuele Dietler <<a href="mailto:samuele_82@hotmail.com" target="_blank">samuele_82@hotmail.com</a>>:<br>> > Hi ITK users,<br>> > there is a way to force to destroy an object or we should wait for<br>
> > autodiscruction by set the object to NULL value???<br>> > Thank you, best<br>> > Samuele<br>> ><br>> > ________________________________<br>> > Windows Live: tieni aggiornati i tuoi amici sulle tue attività in linea.<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>> ><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>