• Advertisement
Sign in to follow this  

mipmapping and memory leaks

This topic is 1962 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've never played around with mipmapping so I thought I would give it a try. Everything works well, but gDEBugger reports "Memory Leak: 9 object(s) are leaked in GL Context 1" when it is deleted. The only thing that it can be are the nine mipmap levels, since no other GL objects are allocated.

This is the code I use to load the texture:
void LoadTestTexture(void)
long i;
string str;
texture *test_tex;
for(i = 0;i < 9;i++)
test_tex = new texture;
str = "data/";
str.append(1,(char)(i + '0'));
cout << str.c_str() << endl;
cout << test_tex->GetImageWidth() << endl;
cout << test_tex->GetImageHeight() << endl;
delete test_tex;

I plan on using rendered textures, so I am loading the mipmap levels manually rather than relying on gluBuild2DMipmaps. As you can see, this function loads the texture file into memory, calls glTexImage2D and deletes the texture from system memory. When the program exits, I call glDeleteTextures on "test_tex_ID". Having no further control over the texture memory, I thought this would be enough.

The program is really very simple. I create the context, load the mipmaps and bind them and then draw a quad moving (using immediate mode for coding speed) towards and away from the camera to test the mipmaps. That's it. Other than the textures, no other GL objects are allocated and all allocated memory is deleted on program exit.

It seems like this leak is coming from the driver. Is this normal? Edited by MarkS

Share this post

Link to post
Share on other sites
Never mind. I thought to look in the texture class and saw that "LoadTexture" called "glGenTextures" each time. It also failed to call "glDeleteTextures" in the destructor. I need to rewrite the texture class anyway.

Problem solved. Edited by MarkS

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement