dexfx

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

Discussion created by dexfx on Jan 17, 2011
Latest reply on Jan 23, 2011 by 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

Outcomes