My code approaches GLSL shader management in the way, that it creates each shader and the associated program and deletes each shader and program. I recently read http://www.opengl.org/wiki/GLSL_Object and there it is stated that:
The shader object, due to being attached to the program object, will
continue to exist even if you delete the shader object. It will only
be deleted by the system when it is no longer attached to any program
object (and when the user has asked to delete it, of course).
Do I get this correctly, if I call glDeleteShader() on the shader object after linking to the program, I only need to track the program? Is it safe to assume this is always true?
Yes — in fact it is highly desireable to detach and delete your shader objects as soon as possible. That way the driver can free up all the memory it is using to hold a copy of the shader source and unlinked object code, which can be quite substantial. Measurements I have done indicate that NOT deleting the shader objects increases the incremental memory use per shader by 5-10x