Sohaib,
I experienced exactly the same behavior on my Qt based project. After
much pain and anguish I determined that this is a bug in Qt 4.2. I
even reported it as a bug and worked through a couple of iterations
with the Qt tech support. To make a long story short, you will find
that things work better in either Qt 4.1.5 or Qt 4.3. I could never
get multiple contexts working satisfactorily under Qt 4.2.2.
Hope this helps.
-RobF
On Jun 12, 2007, at 4:01 AM, Sohaib Athar wrote:
Hello everyone,
We have a QT based application that is exhibiting some
strange (to us) memory leak problems, and we can't
figure out the cause, and would appreciate some
help/pointers.
After a lot of debugging, We have isolated the problem
scenario as follows:
The application is QT 4.2 based, with a
osg::Viewer+QGLWidget derived window as the central
widget, and another osg::Viewer/QGLWidget drived
widget in a dock widget that is shown/hidden on
demand. Both views are sharing a scenegraph with
different nodemasks, and are based almost completely
on the QTViewer example in SVN.
The problem:
When we have only one viewer window (the main central
widget, with the 2nd window commented out), everything
is running fine.
The problem starts when the 2nd view is added to the
program... we start getting memory leaks on every
updateGL call in the 2nd window, if we use an idle or
a 10ms QTimer in the 2nd window.
If we disable the QTimer, memory usage still increases
when we call updateGL on demand from the main
application.
We have tried a minimum class with NO scenedata as the
2nd view (code snippets below) and the memory leaks
still occur. This results in application crash after
an hour or so (depending on the system memory). We
have attached no callbacks anywhere, so there
shouldn't be any dynamic memory allocation happening
from the application end if the user is just watching
the screen (there are no animations).
If we disable all calls to updateGL() for the second
view, the memory leaks stop.
What could be happening with a viewer with no
scenedata to be using up memory on every updateGL? It
could be something very basic but I'm out of guesses,
please help.
Thanks,
Sohaib Athar.
The stripped down code for the 2nd view class is:
///// FROM THE HEADER
class BTFreeView : public QGLWidget, public
osgViewer::Viewer {
Q_OBJECT
public:
BTFreeView(QWidget *parent, BTDocBase* pDoc2D, int
contextID);
virtual void paintGL();
osgViewer::GraphicsWindow* getGraphicsWindow() {
return _gw.get(); }
const osgViewer::GraphicsWindow* getGraphicsWindow()
const { return _gw.get(); }
protected:
virtual void resizeGL( int width, int height );
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
};
#endif // BTFreeView_H
////// FROM THE CPP
BTFreeView::BTFreeView(QWidget *parent, BTDocBase*
pDoc, int contextID) {
_gw = new
osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
getCamera()->setGraphicsContext(getGraphicsWindow());
setThreadingModel
(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext);
setFocusPolicy(Qt::ClickFocus);
}
void BTFreeView::paintGL()
{
frame();
}
void BTFreeView::resizeGL( int width, int height ) {
_gw->getEventQueue()->windowResize(0, 0, width,
height );
_gw->resized(0,0,width,height);
}
______________________________________________________________________
______________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/