Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt OpenGL memory leak
Forum Updated to NodeBB v4.3 + New Features

Qt OpenGL memory leak

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nikoko
    wrote on 1 Mar 2013, 13:29 last edited by
    #1

    Hello

    A have a strange behavior in my Qt OpenGL widget based application.
    I just define a widget (inherit from QGLWidget) and in the paintGL function draw large number of 2D lines (1000 x 1000 for test)
    A define a timer wich tick updageGL slot each 20 ms
    The memory takes 10mo each second until process reach 1Go and then memory usage drop to 20mo and restart growing, ...

    If, after painting my lines, I just put an instruction like glCallList () (which just draw 1 line), there is no more memory leaks (and all my previous lines are draw !!!)

    I have the same behavior with QT4.8.2 and VS 2008 and Qt5.0.1 with VS 2010.

    I dont understand why put a glCallList (or drawTExt for example) resolved the memory leak.

    My confiuration : Windows 7 64bits (compilation with x86) pro 8Go RAM Nvidia Quadro 1000M

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Mar 2013, 13:56 last edited by
      #2

      Hi,

      A look at your code would help us help you

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nikoko
        wrote on 1 Mar 2013, 14:26 last edited by
        #3

        Here is the paintGL function :

        @
        void MyGLWidget::paintGL ()
        {
        glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glColor3f (0.5,0.,0.);
        for (int i = -1000; i <= 1000; i += 1)
        {      
            glLineWidth(1.0);
            if (!(i))
            {
                glLineWidth(2.0);
            }
        
            glBegin    (GL_LINES);
            glVertex3i (i, -1000, -1);
            glVertex3i (i, 1000, -1);
            glEnd();
        
            glBegin    (GL_LINES);
            glVertex3i (-1000, i, -1);
            glVertex3i (1000, i, -1);
            glEnd();
        }
        
        glCallList (dummyLineId);
        

        }
        @

        With line glCallList (dummyLineId); no problem, without it, memory growing.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 1 Mar 2013, 14:45 last edited by
          #4

          That's indeed strange... The code looks fine to me.

          Since your vertices don't change, did you consider to use a vbo ? That would speed up things and you would only allocate the memory once.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nikoko
            wrote on 1 Mar 2013, 14:53 last edited by
            #5

            In fact, all code is now in display lists, so no more problem :)
            But I want to understand why the memory increase with this simple drawing.
            A can have this problem in another situation so if i can understand with preformances are so strange it will be helpfull

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 1 Mar 2013, 15:01 last edited by
              #6

              Only triangles are simple !

              More seriously, there can be several things that can interfere, the underlaying gl implementation, the nvidia drivers etc...

              Does it also happen when you tick updateGL at a slower pace ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nikoko
                wrote on 1 Mar 2013, 15:22 last edited by
                #7

                Yes, it always happen !
                Purhaps OpenGL implementation in Qt (if a try to do the same thing in glut api for example,no problem).

                1 Reply Last reply
                0

                1/7

                1 Mar 2013, 13:29

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved