Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMarkS

Posted 07 September 2012 - 08:59 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?

#1MarkS

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, since nothing else is allocated are the mipmaps.

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?

PARTNERS