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

Memory leak of QOpenGLContextGroup object

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.0.0
    • Fix Version/s: 5.0.2
    • Component/s: GUI: OpenGL
    • Labels:
      None
    • Environment:
      Windows 7 x64
      vs2010
    • Commits:
      b188d9481b98680deb7f44fb41f8eafce18aedab

      Description

      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.

        Attachments

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

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes