I’m just starting to add libsdl (1.2.10) into my 3D engine and after running
my engine with Compuware’s DevPartner I found a few memory leaks. I have
been reading the libsdl documentation and I don’t think I’m doing anything
wrong. You can see the DevPartner output in
http://www.pablo-zurita.com.ar/gallery/screenshots/sdl_leak?full=1 and the
code I wrote is here:
bool SdlWindow::initialize()
{
if(SDL_Init(SDL_INIT_VIDEO) != 0)
return false;
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if(!SDL_SetVideoMode(640, 480, 32, SDL_OPENGL))
return false;
return true;
}
void SdlWindow::terminate()
{
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_Quit(); //I also tried atexit but the same memory leaks appear.
}
Just if you wonder, I made sure everything both functions get called, that
they get called in the proper order, and that they execute only once. I
didn’t modify libsdl at all; I got the source code from
http://www.libsdl.org/release/SDL-1.2.10.zip and compiled it in Visual
Studio .Net 2005.
I hope you can help me. Thanks in advance.
Pablo Zurita.