Thanks all for replying,

After set my_ptr = NULL, the unref () of the _ptr is called, in my case,
_ptr is a osg::node(), then the node’s destructor is called and then the
children of that node will all be unref()ed?

I checked the destructor of osg::group, I just saw the remove of the parents
of that node, but nothing is done to its children.

Will the memory of the whole tree be released as soon as I set my_ptr =
NULL, or does it still have to wait until it’s out of scope? 

 

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Thibault Genessay
Sent: 2006?12?13? 15:59
To: osg users
Subject: Re: [osg-users] how to explicitly delete objects protected
byosg::ref_ptr<T>?

 

Hi

On 12/13/06, xiaoshuxing <[EMAIL PROTECTED]> wrote:

Hello, everyone:

Osg::ref_ptr is used automatically manage the memory allocation, but it only
release the memory when the point is out of scope

What should I do if I want to release the memory the pointer is pointing to
explicitly?


Just write my_ptr = NULL, this will unref() the root object and delete it
(as long as it's not referenced by any other osg::ref_ptr). This will
trigger the recursive unref() chain that you tried to do manually.

Regards 

-- 
Thibault

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to