Why does valgrind say basic SDL program is leaking memory?

假装没事ソ 提交于 2019-11-27 13:58:56

Even for basic OpenGL "hello world" program without the full SDL, Valgrind gives me similar warnings deep inside the OpenGL libraries. It's peculiar, but I've assumed

  • The library implementors know what they're doing (probably preallocating some small static buffers they never bother to free),
  • Even if they don't, it's a one-time leak that'll be reclaimed by the OS when the program terminates,

and haven't lost much sleep over it.

SDL definitely has a memory leak issue with SDL_TLSCleanup and SDL_TLSData.

In fact, SDL_TLSCleanup is never called for the main thread.

Every SDL_Surface you load should be freed before the call of SDL_Quit().

To do this, just use SDL_FreeSurface(surfaceName) to free up the surface that you allocated on memory.

Singletons are pretty much always a 'leak' with standard implementations. That is usually ok, though, since normally it's not like you want to unload your ability to do things like print to the console.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!