Jump to content

  • Log In with Google      Sign In   
  • Create Account


mipmapping and memory leaks


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 MarkS   Prime Members   -  Reputation: 875

Like
0Likes
Like

Posted 07 September 2012 - 08:56 AM

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;

glGenTextures(1,&test_tex_ID);

glBindTexture(GL_TEXTURE_2D,test_tex_ID);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);

for(i = 0;i < 9;i++)

{

  test_tex = new texture;

  str = "data/";

  str.append("level",5);

  str.append(1,(char)(i + '0'));

  str.append(".tga\0");

  cout << str.c_str() << endl;

  test_tex->LoadTexture(str.c_str());

  cout << test_tex->GetImageWidth() << endl;

  cout << test_tex->GetImageHeight() << endl;

  glTexImage2D(GL_TEXTURE_2D,i,GL_RGBA,test_tex->GetImageWidth(),test_tex->GetImageHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,test_tex->GetImageData());

  str.clear();

  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, 07 September 2012 - 08:59 AM.


Sponsor:

#2 MarkS   Prime Members   -  Reputation: 875

Like
0Likes
Like

Posted 07 September 2012 - 09:39 AM

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, 07 September 2012 - 09:39 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS