Cary, Karl A. wrote on 2012-10-15: 
> 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.

Hi Karl,

Those uniforms are stored inside StateSet using ref_ptr<> (see the
StateSet::RefUniformPair type), so they will be deleted when your geo is
deleted, they will be removed too (as long as nothing else has a ref_ptr
pointing to them).

Hope this helps,
--
Bryan Thrall
Principal Software Engineer
FlightSafety International
[email protected]

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

Reply via email to