Hi all,
The osgoit example program exhibits a large memory leak when the
window is continually resized causing the depth peel cameras
to be recreated over and over. This leak is made much worse
when the program is modified for multi-sampled antialiasing...
// camera->attach(osg::Camera::COLOR_BUFFER, colorTexture.get());
camera->attach(osg::Camera::COLOR_BUFFER, colorTexture.get(),
0, 0, false, 4, 4);
I suspect that each time it sets up the cameras a new FBO is allocated
without releasing previously used FBO resources as described in
the threads "FBO resizing problem" and "[osgPPU] Problems with resizing".
How would one go about managing FBOs without leaking memory in the context
of osgoit? A callback on resize such as the one below was suggested in
one (actually both) of the threads mentioned. If this is appropriate,
where does it fit in?
class detachFBOCallback : public osg::NodeCallback {
public:
detachFBOCallback( ) {}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::Camera* fboCam = dynamic_cast<osg::Camera*>( node );
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( nv );
if ( fboCam && cv )
{
// Cause the FBO to be recreated.
cv->getCurrentRenderBin()->getStage()->setFrameBufferObject(NULL);
// Ensure that runCameraSetUp is called.
cv->getCurrentRenderBin()->getStage()->setCameraRequiresSetUp(true);
}
traverse( node, nv );
}
};
-Don Leich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org