Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29056

Memory leak of QOpenGLContextGroup object

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.0.2
    • 5.0.0
    • GUI: OpenGL
    • None
    • Windows 7 x64
      vs2010
    • b188d9481b98680deb7f44fb41f8eafce18aedab

      The following code can demonstrate this leak:

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QGLWidget w;
          w.show();
          int ret = a.exec();
      
          int nCrtDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
          nCrtDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
          _CrtSetDbgFlag(nCrtDbgFlag);
      
          return ret;
      }
      

      Run this program in debug mode (Press F5), and you can see memory leak report at exit.

      The leaked object is QOpenGLContextGroup object. Since QOpenGLContextGroup object
      is desgned to be destroyed by deleteLater(), but this method will not always work due to the fact
      that in many cases event loop will exit before the deferred deletion of the QOpenGLContextGroup
      object is queued. As we can see in the above program, the event loop will exit before QGLWidget object's
      destruction. This will cause the QOpenGLContextGroup object hold by QGLWidget object never been deleted.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jianliang79 liang jian
            jianliang79 liang jian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes