Hi John, Since StateSet uses ref_ptr<> internally for all StateAttribute, and merge doesn't create anything on the heap - it just copies then it's pretty unlikely there is a memory leak.
Far more likely is that the tool you are using for tracking memory leaks is faulty. Could you please explain what makes you think you have a memory leak? Robert. On Wed, Jun 3, 2009 at 7:44 PM, John Kelso <[email protected]> wrote: > Hi, > > I have discovered that this line of code: > > toNode->getOrCreateStateSet()->merge(*(fromNode->getOrCreateStateSet())) > ; > > seems to cause a memory leak. I busted it up: > osg::StateSet *fromNodeStateSet = fromNode->getOrCreateStateSet() ; > osg::StateSet *toNodeStateSet = toNode->getOrCreateStateSet() ; > toNodeStateSet->merge(*fromNodeStateSet) ; > > and it still leaks. If I comment out the third line the leak goes away. (I > print the pointers, so hopefully the optimizer doesn't just toss all three > lines.) > > Using either of these commands, although less than useful: > toNodeStateSet->merge(*toNodeStateSet) ; > fromNodeStateSet->merge(*fromNodeStateSet) ; > doesn't cause the leak. > > Both nodes have StateSets, so this also works, and also leaks: > osg::StateSet *fromNodeStateSet = fromNode->getStateSet() ; > osg::StateSet *toNodeStateSet = toNode->getStateSet() ; > toNodeStateSet->merge(*fromNodeStateSet) ; > > I'm sort of stumped, and hoping the group might have some suggestions of > what > might be the source of the leak. > > I'm using OSG Version 2.6.1, Linux. > > Many thanks, > > John > > _______________________________________________ > 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

