In the destructor of the node/nodes perhaps Thats where I would place a break point
________________________________________________________________________ Capture the magic of Christmas this year see http://www.capturethemagic.com ____________________________________________________________________________ __ Gordon Tomlinson [email protected] IM: [email protected] www.vis-sim.com www.gordontomlinson.com ____________________________________________________________________________ __ -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Andreas Goebel Sent: Monday, December 15, 2008 8:46 AM To: OpenSceneGraph Users Subject: Re: [osg-users] ref_ptr needed for this? Ulrich Hertlein schrieb: > On 15/12/08 6:45 PM, Andreas Goebel wrote: >> TheGeometry->addPrimitiveSet(new >> osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,numCoords)); >> ... >> I ask myself if this will give a memory-leak, or if this is ok, as the >> pointer is directly passed to the TheGeometry-object (which lives in a >> ref_ptr). > > Exactly. Because it's passed to a ref_ptr it won't leak. You could > also assign it to a local non-ref_ptr and it still would be OK. > > The more likely error case is stale objects (holding a non-smart > pointer to a deleted object), not memory leaks because the object is > held (and eventually deleted) in a ref_ptr inside OSG. > > Cheers, > /ulrich > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > Thanks. As the topic is related: Do you know where I have to set a breakpoint to see if an object like a node really gets deleted? I want to free some memory. Therefore I remove the node (and some other stuff) from the scene-graph like this: if (TheNode.get() ){ osg::Node::ParentList parents = TheNode->getParents(); for(osg::Node::ParentList::iterator pitr=parents.begin(); pitr!=parents.end(); ++pitr) { (*pitr)->removeChild(TheNode.get()); } } And then remove the reference like this: TheNode= NULL; So if I really got all references removed, it should delete the node, right? I have the impression that the node doesn´t get deleted (I created some hundred nodes for testing and removed them this way, memory-consumption didn´t go down), so either my approach is wrong, or I forgot some reference somewhere. Regards, Andreas _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

