Massive Memory Leaks |
MrTAToad
|
After rendering the text, you need to destroy the texture and surface - each TTF call creates a new surface!
|
|||||||||||
|
dwrj87
|
I have SDL_FreeSurface(surface); and SDL_DestroyTexture(texture); in there. Is there something else I should be doing to destroy them?
|
|||||||||||
|
Naith
|
Try moving 'SDL_FreeSurface(surface)' to be called after 'SDL_RenderCopy(renderer, ....)' and before 'SDL_DestroyTexture(texture)', i.e:
Also, to optimize the code, you should insert the SDL_PollEvent-call into a while loop so it's only called whenever a event is occuring, i.e:
|
|||||||||||||||
|
MrTAToad
|
Ah yes - didn't see them there
Is the output variable a std::string or something else ? If its the latter, perhaps you need to free that. |
|||||||||||
|
dwrj87
|
Yes, output is a std::string
I have added a while loop around the event polling I'm also afraid that the memory leak has disappeared. Posted the code today once my group membership was confirmed, ran it for the first time in a few days and no leak :S I'm afraid that I really can't explain it sorry :S |
|||||||||||
|
Naith
|
Glad it turned out alright. =)
|
|||||||||||
|