[osg-users] Clear scene data and underlying memory structures

Bruno Oliveira bruno.manata.oliveira at gmail.com
Fri May 13 01:41:28 PDT 2016


Hello,

I have spent a great deal of time trying to figure out OSG's memory
management.
I have a scene graph with several children (actually a LOD based on an
octree).

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

    // Clear main osg::Group root node
    m_rootNode->removeChildren(0, m_rootNode->getNumChildren());
    m_rootNode->dirtyBound();

    // Clear Main view scene data from osg::Viewer
    m_viewer->setSceneData(nullptr);


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.

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)

I can't have this behaviour, as I need to closely control memory usage. How
can I do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160513/92caaf86/attachment-0001.htm>


More information about the osg-users mailing list