Reputation: 1253
Are there any know methods or functions in SDL known to cause memory leaks?
I noticed for my program that as time when on, .1 MB of memory kept on being tacked onto the program's memory usage (ie. an extra '.4 MB' were added in exactly 3 minutes).
I commented out all of my surface drawing/bliting functions; pretty much just isolated the main game loop to the event structure and screen flipping, ex:
// .. Intilize
char quit = 0;
Uint8* keystate = NULL;
SDL_Event hEvent;
while (!quit)
{
// .. Code
while (SDL_PollEvents(&hVvent)) {
keystate = SDL_GetKeystate(NULL);
// .. Event processing
}
// .. More Code
if (SDL_Flip(screen) == -1)
return 1
SDL_Delay(1);
}
// .. Cleanup
Upvotes: 3
Views: 546
Reputation: 11
valgrind --track-origins=yes --leak-check=full --show-reachable=yes ./executable
Upvotes: 1
Reputation: 1840
My favourite tool to check for memory leaks is Valgrind. After compiling your code, just run the following command:
valgrind --leak-check=full --show-reachable=yes ./executable
After finishing, check the output for memory leak information. The tool can be more verbose, by issuing the -v flag
Upvotes: 1