<div dir="ltr"><div><div><div><div><div><div>Hello,<br><br></div>I have spent a great deal of time trying to figure out OSG's memory management.<br></div>I have a scene graph with several children (actually a LOD based on an octree).<br><br></div>However, when I need to reset my scene (I just want to wipe ALL nodes from de scene and also wipe the memory), I use <br><br></div><div>    <span style="color:rgb(106,168,79)">// Clear main osg::Group root node</span><br></div><div>    m_rootNode->removeChildren(0, m_rootNode->getNumChildren());<br>    m_rootNode->dirtyBound();<br><br></div><div>   <span style="color:rgb(106,168,79)"> // Clear Main view scene data from osg::Viewer</span><br></div><div>    m_viewer->setSceneData(nullptr);<br><br><br></div>BEFORE I do this, I check all my nodes with a NodeVisitor pattern, and found out that ALL my nodes have reference count of 1, i.e, after clearing them from the scene, I expect my memory to be freed. However, this does not happen: my scene is actually reset, all the nodes disappear from the viewer, but the memory remains occupied.<br><br></div>Nonetheless, when I load another scene to my viewer, the memory is rewritten somehow (i.e., the memory usage does not increase, hence there is no memory leak, but used memory is always the same)<br><br></div>I can't have this behaviour, as I need to closely control memory usage. How can I do this?<br><div><div><div><div><br></div></div></div></div></div>