FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory leaks with SDL resizing and unloading textures

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
wolftousen



Joined: 28 Jan 2008
Posts: 10

PostPosted: Mon Oct 12, 2009 4:22 pm    Post subject: Memory leaks with SDL resizing and unloading textures Reply with quote

Ok, so i've spent the better part of my day tracking down some memory leaks in my app. I though initially they were caused by Tangos File classes, but finally ruled that out.

Here are the memory leaks:
DerelictSDL:
When i go to resize a window, my mem usage increases by ~150K in the task manager (yeah i know it's not the best...).
When the app takes input i get random increases of ~8k.

//resize code
Code:
void InitializeSDL()
{
   SDL_SetVideoMode(width, height, 24, SDL_OPENGL | SDL_DOUBLEBUF | SDL_RESIZABLE);
   glViewport(0, 0, width, height);   
   
   glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   glClearDepth(1.0);
   glPushColor(255, 255, 255);
   glDepthFunc(GL_LEQUAL);
   glEnable(GL_TEXTURE_2D);
   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   glShadeModel(GL_SMOOTH);

   // switch to the projection mode matrix
   glMatrixMode(GL_PROJECTION);

   // load the identity matrix for projection
   glLoadIdentity();

   // setup a perspective projection matrix
   gluOrtho2D(0, width, 0, height);
   //gluPerspective(90.0f, cast(float)(400 / 300), 0.1f, 100.0f);

   // switch back to the modelview transformation matrix
   glMatrixMode(GL_MODELVIEW);

   // load the identity matrix for modelview
   glLoadIdentity();
   
   glLineWidth(1);
}

DerelictOpenGL:
When I load textures with glTexImage2D, it should be putting that data on the gfx card memory correct? It is registering in the task manager as my current mem usage goes up ~size of the texture data and doesn't go back down after I delete it on my end.

Every time i reloaded textures it goes farther up in the same increment.
Code:
oImage textureData;
      glEnable(GL_TEXTURE_2D);
      foreach(texture; m_loadedTextures)
      {
         textureData = oImage.LoadImage(texture.GetFile());
         
         uint[] dims = textureData.GetDimensions();

         //if the image width and height are not a power of 2, scale the image to the closest powers of 2...
         glDeleteTextures(1, texture.GetID());
         glBindTexture(GL_TEXTURE_2D, *(texture.GetID()));
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
          
         if(dims[2] == 3)
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, dims[0], dims[1], 0, GL_RGB, GL_UNSIGNED_BYTE, cast(void*)textureData.GetPixelData());
         else
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims[0], dims[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, cast(void*)textureData.GetPixelData());
         
         delete textureData;
      }


I'm on Win XP, using the latest Tango and Derelict packages, can anyone duplicate or know of this issue?

Thanks in advance.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group