I seem to be getting memory leaks when I resize the screen, like when
a SDL_VIDEORESIZE message arrives. (I am using a basically unmodified
version of the sample SDL tutorial program from http://www.meandmark.com/sdlopenglpart1.html.)
Rather than resize the screen a bunch of times, I moved my screen
resize code to be bound to the SDLK_TAB key.
if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_TAB)
{
SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
gluOrtho2D(0.0, 4.0, 0.0, 3.0);
}
So I hit this key repeatedly, each time it recreates the new window,
and the window looks fine. And I look in Activity Monitor (I am
programming on a mac by the way) and each time I resize it like this I
use more and more memory. After hitting the key about 30 times, it is
a pretty unwieldy chunk of memory.
Is this a bug? Is there more I should be freeing? I know the OpenGL
context is destroyed with the old window, thus making me do another
gluOrtho2D call. Is there anything I am forgetting to free?
I have read that I don’t have to free the previous screen. Is that
true?
I have even tried calling SDL_FreeSurface(SDL_GetVideoSurface());
before SDL_SetVideoMode, but the memory leak is still there.
Any ideas?
-Trevor Agnitti
www.lackeyccg.com