0

When I checked my Application for leak with Instruments (X-Code Tool, I program in objective-c), I saw the #living "malloc 48 bytes" allocations growing bigger and bigger. Also, Instruments does say that it leaks there. If I check for the Responsible caller, it always says "gluNewQuadric". I checked the internet for a bit and found some people are having the same complaints, but not too many, and I also found no working solution. I also put

glutInit(&argc, argv);

in "main.m", and the increase of #living seems to have gone down a bit, but is still growing persistently. The only place where I use glu is with

glutSolidSphere
glutWireSphere

Any suggestions on how to fix this?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Ivorius
  • 160
  • 1
  • 8
  • Are you calling `gluDeleteQuadric`? – Piotr Praszmo Jul 12 '11 at 11:36
  • No. What Quadric should I delete? glutSolidSphere seems to cause the problem, and gluNewQuadric is invoked inside glutSolidSphere, and I don't get the sphere as a return value or something... – Ivorius Jul 12 '11 at 12:24
  • Instead of `glut*Sphere` use `gluSphere` directly. Your glut implementation is probably not freeing `GLUquadricObj` correctly. – Piotr Praszmo Jul 12 '11 at 13:06
  • I've the same problem on OSX 10.6.8, my solution was to substitute the glutSolidSphere call with the following: `GLUquadricObj *quadricSphere=gluNewQuadric();` `gluQuadricNormals(quadricSphere, GLU_SMOOTH);` `glPushMatrix();` `glTranslatef(x, y, z);` `gluSphere(quadricSphere,radius,stacks, sectors);` `glPopMatrix();` `gluDeleteQuadric(quadricSphere);` – linello Dec 11 '12 at 10:17

1 Answers1

2

Here's a pro-tipp: Don't use GLUT rendering primitives. They are there for quick testing and not meant for serious bussines. A few weeks ago I posted two lengthy answers on how to draw a sphere using pure OpenGL without resorting to GLU or GLUT:

Community
  • 1
  • 1
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • That's some solution x) But, with the help of your tutorial, I at least will be able to use Spheres further. Thanks :) – Ivorius Jul 12 '11 at 13:39