Possible Bug Report – Linux memory leak when updating buffers

When updating buffers via “glMapBuffer and glUnmapBuffer” or “glBufferSubData”. I noticed a memory leak in the CPU memory. However, this memory leak was not able to be captured in Valgrind and was only noticeable through the Linux “top” command. After several hours of debugging and researching I came to the conclusion that OpenGL was not releasing the memory that it allocates when copying buffer data to the GPU memory.

In my code I would delete a buffer then turn around and create a new buffer. OpenGL was giving me the same buffer name/number to use for this new buffer, as the one that was just deleted. I then proceeded to update the buffer data. I imagine that the buffers were ending up in a weird state that kept the previous buffers from being flagged for deletion and constantly allocating new buffer data.

Since the memory leak was only noticeable with larger buffers (81785184 bytes). It seemed like this could be a possible bug that I should report.

To fix this issue I had to invalidate the buffer data before deleting the buffer. For OpenGL 3.2 I did this by calling glBufferData() with a Null pointer and size of 0 bytes.

This memory leak was seen on a GTX 680 and GTX 980. With both Linux drivers 346…47 and 358.09.