[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


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?


/* Adding the layer */

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

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 *****/

Am I doing something wrong? 

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

Many thanks for your help!!


Read this topic online here:

More information about the osg-users mailing list