commit 27f3249e824bca366e6447d426883eb9166efcc0 parent fea53becc2ff8f2fa5137e40e75beaac39af9829 Author: Michael Savage <mikejsavage@gmail.com> Date: Sat Feb 6 17:08:19 +0000 Add GL object leak checker Diffstat:
gl.cc | | | 20 | ++++++++++++++++++++ |
diff --git a/gl.cc b/gl.cc @@ -114,6 +114,26 @@ GLFWwindow * gl_init() { return window; } +// https://gist.github.com/rygorous/9559632 +static void gl_check_for_leaks() { + GLuint max_id = 10000; // better idea would be to keep track of assigned names. + + // if brute force doesn't work, you're not applying it hard enough + for( GLuint id = 1 ; id <= max_id ; id++ ) { +#define CHECK( type ) if ( glIs##type( id ) ) fprintf( stderr, "GLX: leaked " #type " handle 0x%x\n", (unsigned int) id ) + CHECK( Texture ); + CHECK( Buffer ); + CHECK( Framebuffer ); + CHECK( Renderbuffer ); + CHECK( VertexArray ); + CHECK( Shader ); + CHECK( Program ); + CHECK( ProgramPipeline ); +#undef CHECK + } +} + void gl_term() { + gl_check_for_leaks(); glfwTerminate(); }