I’ve been messing about with creating multiple windows, and renderers for each said window, and ran into a problem when it comes to destroying the renderer, but not quitting SDL.
What I’ve been using :
Code:
//to create renderer
SDL_Renderer* ren_01;
//to initialize it
bool init_win_01()
{
…
ren_01 = SDL_CreateRenderer(win_01, -1, SDL_RENDERER_ACCELERATED);
…
}
//to clear it, and try to remove it from the RAM
bool close_win_01()
{
SDL_DestroyRenderer(ren_01);
//since this didn’t free the additional ram used by the program i added
ren_01 = NULL;
//Still didn’t free the additional ram used by the program
}
I did checks to make sure the renderer equated to NULL, and it did, but the amount of ram the program used remained the same, and when re-initializing the window when the code to open it gets called again, more and more ram is added, creating a memory leak.
Use a tool like valgrind… Simply looking at the process memory usage will
not do the trick.On Sep 29, 2013 4:47 PM, “nigisub” wrote:
**
I’ve been messing about with creating multiple windows, and renderers for
each said window, and ran into a problem when it comes to destroying the
renderer, but not quitting SDL.
What I’ve been using :
Code:
//to create renderer
SDL_Renderer* ren_01;
//to initialize it
bool init_win_01()
{
…
ren_01 = SDL_CreateRenderer(win_01, -1, SDL_RENDERER_ACCELERATED);
…
}
//to clear it, and try to remove it from the RAM
bool close_win_01()
{
SDL_DestroyRenderer(ren_01);
//since this didn’t free the additional ram used by the program i added
ren_01 = NULL;
//Still didn’t free the additional ram used by the program
}
I did checks to make sure the renderer equated to NULL, and it did, but
the amount of ram the program used remained the same, and when
re-initializing the window when the code to open it gets called again, more
and more ram is added, creating a memory leak.