2

this program:

#include <iostream>
#include <SDL2/SDL.h>

/*
 * Lesson 0: Test to make sure SDL is setup properly
 */
int main(int argc, char** argv){
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
        return 1;
    }
    SDL_Quit();

    return 0;
}

compiled using g++ -o main main.cpp -lSDL2; valgrind ./main produces the following output:

==21646== HEAP SUMMARY:
==21646==     in use at exit: 108,320 bytes in 582 blocks
==21646==   total heap usage: 16,412 allocs, 15,830 frees, 106,043,200 bytes allocated
==21646== 
==21646== LEAK SUMMARY:
==21646==    definitely lost: 12,058 bytes in 4 blocks
==21646==    indirectly lost: 0 bytes in 0 blocks
==21646==      possibly lost: 0 bytes in 0 blocks
==21646==    still reachable: 96,262 bytes in 578 blocks
==21646==         suppressed: 0 bytes in 0 blocks

Is this something I should be worried about, and if so, how do I know the difference between false positives and actual bugs in my code?

a797788
  • 21
  • 2

1 Answers1

0

Taken from this stackoverflow answer


In your specific case, I would run valgrind with the flags --leak-check=full --track-origins=yes --show-reachable=yes, see if the leak is really coming from SDL

Community
  • 1
  • 1
saloomi2012
  • 337
  • 2
  • 12