Hi Karl,

On 16/10/12 2:53, Cary, Karl A. wrote:
> I am tracking down some memory leaks in our program and have come across a 
> couple
> situations where I am currently not sure if it is/can cause a memory leak. 
> There are many
> instances in our code where we do something similar:
> 
> osg::ref_ptr<osg::Geometry> geo  = new osg::Geometry;
> geo->getOrCreateStateSet()->addUniform(new osg::Uniform(“blah”, someVal));
> geo->getOrCreateStateSet()->addUniform(new osg::Uniform(“blah2”, someVal2));
> 
> What I am wondering is, will osg now clean up those 2 new uniforms? Or do I 
> need that be
> created externally as ref_ptrs so when my object deletes they will be 
> deleted? I
> personally want to change it to ref_ptrs, but given the number of places this 
> change needs
> to be made, I at least want to know if the work is truly needed or not.

Since you're not using them yourself you don't have to use ref_ptr in this case.
The new'd Uniforms are assigned to ref_ptr members of osg::StateSet and are 
cleaned up
when that object goes away (or rather, they are unref'd and deleted if no one 
else is
using them).

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to