Problem. I have inherited a large C++ 3D graphics codebase (with some shader code). The program runs for about 1-5 minutes before crashing.

Problem Data. Using system tools, one can see a sharp rise in VRAM memory usage after the program launches, which eclipses into a crash. The same is true for GTT memory usage also (although the spike isn't quite as dramatic as with the VRAM).


  1. Does this (probably) mean that there is a memory leak in OpenGL shader code somewhere (as opposed to a leak in regular C++ code)?

  2. Are there well-known tools for tracking down vram/gtt memory leaks (similar to the way that valgrind can be used to track down system memory usage)?

  • 1
    \$\begingroup\$ Is it even possible for shader languages to leak memory? My first guess would be that C++ code keeps pushing data to the GPU which it never frees. \$\endgroup\$ – Philipp Mar 20 '17 at 16:40
  • \$\begingroup\$ @Philipp: Good question. But how would C++ code push data to the GPU outside of shader code? \$\endgroup\$ – George Mar 20 '17 at 16:41
  • 2
    \$\begingroup\$ By calling functions like glTexImage2d, for example. \$\endgroup\$ – Philipp Mar 20 '17 at 16:53
  • \$\begingroup\$ Shaders can not leak memory. \$\endgroup\$ – Justin William Stanley Bryant Mar 20 '17 at 22:56
  • \$\begingroup\$ What OS are you on? there are different tools for different operating systems. \$\endgroup\$ – user1118321 Mar 21 '17 at 4:53

Browse other questions tagged or ask your own question.