[osg-users] Reference Count too high and memory not being freed

Adrian Jelffs adrian.jelffs at makai.com
Fri Apr 20 20:09:59 PDT 2018


Hello,

I am add a layer to my scene using osgEarth. I am using a ref_ptr but when I come to remove the layer I find that my ref_ptr is in the 1000's. It looks like it goes up everytime I call frame().

Why would this be?


Code:

/* Adding the layer */

osg::ref_ptr<ImageLayer> imageryLayer = NULL;
TMSOptions tmsOptImg;
tmsOptImg.url() = url;
imageryLayer = new ImageLayer(name, tmsOptImg);
_map->addImageLayer(imageryLayer);


Only thing that runs in between is frame() from a different thread

/* Removing Layer */

osg::ref_ptr<ImageLayer> layer = _map->getImageLayerByName(name);
int count = layer->referenceCount(); /***** REF COUNT IS VERY HIGH *****/
_map->removeImageLayer(layer);




Am I doing something wrong? 

Can somebody please explain or give me some suggestions to try?

Many thanks for your help!!

Adrian
[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73473#73473







More information about the osg-users mailing list