SDL Help me to avoid memory leak

My game took 1GB ram after 15 minutes.
I dont know why,I included destructors and cleaned up every pointers

Plz check if out

http://tinypaste.com/5f0337de
In game_updater(), TTF_RenderText_Solid generates a bitmap that you don't ever free.
don't ever free


Thanks,but
You are either :

1. Warning me not to free it.
2. Saying that I didn't free it.

Which one ?
I already freed here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void clean_up( )
{
        if(background != NULL)
                SDL_FreeSurface(background);
        if(pt_game_message != NULL)
                SDL_FreeSurface(pt_game_message);
        if(pt_game_score != NULL)
                SDL_FreeSurface(pt_game_score);
        if(pt_hit_point != NULL)
                SDL_FreeSurface(pt_hit_point);

        if(game_font != NULL)
                TTF_CloseFont(game_font);

        if(music != NULL)
                Mix_FreeChunk( music );

        TTF_Quit();
        Mix_CloseAudio();
        SDL_Quit();
}
I am not looked at the code, but when this cleanup is supposed to be called ? At program exit ? It is kinda useless then, operating system will free the memory for you anyway.

But if you load a bitmap every time and don't free it when you don't need it anymore then the memory grows over time . I think this is the case here.
Well,THanks for the tips ! Problem solved !
Topic archived. No new replies allowed.