3 Replies Latest reply on Jan 23, 2011 10:10 AM by dexfx

    Memory leaking on glDrawElements, with VBO's and multiple shaders

    dexfx

      Hi,

      I've come across a slow system memory leak, on a system with ATI hardware. It occurs only when calling glUseProgram more than once per frame with different shaders..

      In my scenario the leak is removed by only drawing with one shader. If more than one program is used per frame, the leak starts. I don't know of any sample code to reproduce this issue, since opengl doesn't really have any 'samples'. I'm using opengl 2.0 functionality, but it appears to happen when using any shader version. The render code I'm using is similar to the following:

      glUseProgram(..);
      glBindBuffer(GL_ARRAY_BUFFER, ...); //bind vertex buffer
      glVertexAttribPointer(..); //bind vertex element offsets
      glEnableVertexArray(..); //enable vertex elements
      glUniformXx(..); //setting all uniforms
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ..); //bind index buffer
      glDrawElements(GL_TRIANGLES, ...); //draw- leak happens 'here'
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, null); //unbind IB
      glBindBuffer(GL_ARRAY_BUFFER, null); //unbind VB
      //and then repeat using a different shader program

      The shader program is quite basic, simple vertex & pixel shader, with some texturing. The leak happens whether I use textures or not.

      The system spec I'm running is CCC v10.12, Win7 x64, HD5870 x2, i7 920. The system supports opengl 4. I should add that I've run the offending code on two machines with nVidia hardware, and they don't show the symptoms, which indicates it's a problem with the ATI drivers.

      Regards,
      -dexy

        • Memory leaking on glDrawElements, with VBO's and multiple shaders
          frali

          Do you mean there is no memory leak if only one glUseProgram is used, there is obvious memory leak for two and more glUseProgram are used? How long is needed by running the program to see a huge leak?
          How do you check the status of memory? By windows resource monitor? 

          Thanks
          Frank 

            • Memory leaking on glDrawElements, with VBO's and multiple shaders
              dexfx

              That's right... no visible leak if only one glUseProgram called per frame, but starts leaking whenever two or more glUseProgram per frame. The leak is visible immediately on rendering (ie within a few seconds). It seems to leak more the more times I call glDrawElements per frame. Calling glDrawElements 1000 times per frame ends up with a leak at about 2-3kb/sec. I also notice page faults happening at a rate of about 1 or 2 per sec.

              Just using windows task manager to see the private bytes used by the app. There's no visible leak on a machine with nVidia hardware, and a friend of mine tried it on a machine with an older ATI card (can't remember which one), and there was no leak for him there either. So I'm thinking it's something specific to HD5870, or at least the 5000 series. Edit: could also be crossfire related..