There is a skybox class, which loads textures with osgDB::ReadImageFile Those textures get assigned to quads. Later I delete this class. Destructors get called correctly.
polyGeom[i]->getStateSet()->removeTextureAttribute(0,osg::StateAttribute::TEXTURE); With this code, it seems that texture releases memory... but i don't understand it, since it is not in OSG tradition to force me to delete texture.... Texture was created with mTextureList[side] = new osg::Texture2D(); mTextureList[side]->setImage(newImage.get()); mTextureList[side]->dirtyTextureObject(); And assigned with: dstate->setTextureAttributeAndModes(0,mTextureList[side].get(), osg::StateAttribute::ON); polyGeom[side]->setStateSet( dstate.get() ); mGeode->addDrawable(polyGeom[side].get()); The only other unfamilirar thing to me was: mTextureList[side]->setUnRefImageDataAfterApply(true); 2006/11/26, Robert Osfield <[EMAIL PROTECTED]>:
Hi Ivan, On 11/26/06, Ivan Bolčina <[EMAIL PROTECTED]> wrote: > I assign texture to some geometry's state set on constructor of hierararchy: > > dstate->setTextureAttributeAndModes(0,mTexture, > osg::StateAttribute::ON); > > Do I have to do this on destructor to avoid memory leaks: > > dstate->removeTextureAttribute(0,osg::StateAttribute::TEXTURE); > > or not? > > Because if I dont, then memory goes up.... There is no need to remove objects from the scene graph to ensure that memory is properly cleanup, almost all scene graph objects are referenced counted and this includes textures. This is part of the OSG that is thoroughly tested over many years and works solidly. This then leads to the question why you are observing increasing memory usage. For that you'll need to explain a bit more about the platform your are using and how you are using the OSG. Robert. _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
