Skip to content

Instantly share code, notes, and snippets.

@rygorous
Last active August 29, 2015 13:57
Show Gist options
  • Save rygorous/9559632 to your computer and use it in GitHub Desktop.
Save rygorous/9559632 to your computer and use it in GitHub Desktop.
DYI GL object leak checker.
static void check_for_leaks()
{
GLuint max_id = 10000; // better idea would be to keep track of assigned names.
GLuint id;
// if brute force doesn't work, you're not applying it hard enough
for ( 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment