I've noticed that calling glutSolidSphere() seems to leak memory.
Launching the application with MallocDebug shows an increase in
leaks every time I draw one. In particular, it allocates these
quadrics, but apparently never releases them.
I had a quick look through the code for glutSolidSphere (from
glut_shapes.c) and have included some relevant bits at the end.
Basically, GLUT is implemented as a subclassed NSOpenGLView with an
instance variable _quadObj which is shared by all GLUT related calls.
However, this only gets deallocated when the application closes (via
the dealloc method). If you want memory deallocated before
application termination then I guess you have to implement this
yourself using the GLU APIs like gluSphere.
void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
// A helper for quadric objects
GLUquadricObj *__glutGetQuadObj(void)
{
if (__glutViewList == NULL) // This means you never initialized
GLUT - BUT you are still allowed to call glutWireShphere()
// and such anyway. Fixes bug #2742838
return gluNewQuadric();
r i c k
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden