[osg-users] How can I delete skybox from the memory totally

LUO Jianguo luojianguo at tsinghua.org.cn
Fri Jul 24 20:57:43 PDT 2015


Hi,

I am studying how to delete node from root recentlly.
I am so puzzled.
I create a skybox node, then add to root.
then i create a button, click it to create skybox. click again to delete ckybox. click again and again, create, delete.

//not show skybox
	if(!pDoc->m_cSky.m_bShow)
	{   
		//remove node, clear the memory.
		mRoot->removeChild(m_SkyNode);
// 		if(m_SkyNode != NULL)
// 			m_SkyNode.release();
	}
	else
	{
		//create skybox
		if(!m_SkyNode)
			m_SkyNode = pDoc->m_cSky.createSkyBox(m_SkyNode);
		mRoot->addChild(m_SkyNode);
	}

I found if I don't use m_SkyNode.release(), the memory the program using is never changed.
If I use m_SkyNode.release(), the memory increases again and again.

Then I use osg::ref_ptr<osg::Image> in the osg::TextureCubeMap* CCSky::readCubeMap(), no any use for decrease memory.

then I want to free(imagePosX) or delete(imagePosX), which is created by osgDB::readImageFile(CUBEMAP_FILENAME(posx)), error come out, the destructor function is protected.

Can anyone help me? don't ask me why I want to delete it from memory, I just want to know how.

Thank you!

Cheers,
LUO

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




Attachments: 
http://forum.openscenegraph.org//files/skybox_184.h
http://forum.openscenegraph.org//files/skybox_198.cpp





More information about the osg-users mailing list