Memory leaks?

Hello. I am new to SDL, and I decided to make a memory check on my little game :slight_smile:
I saw that I got a lot of strange memory errors, than I created a simple application to check if it was SDL fault.

When I use valgrind to check for memory errors I got 53 leaks detected!
I am compiling the code on Code::Blocks with gcc, I am under Ubuntu. I installed SDL dev files using Synaptic Packet Manager.

Check the attachments for the code and valgrind log! (main.cpp and output.txt)

I used this command to check the application:

“valgrind --tool=memcheck --leak-check=full --show-reachable=yes --log-file=output.txt ./Testing”

Thank you!_________________________________________________________________
Novo Internet Explorer 8. Baixe agora, ? gr?tis!
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8
-------------- next part --------------
A non-text attachment was scrubbed…
Name: main.cpp
Type: text/x-c++src
Size: 299 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/a6c56418/attachment.cpp
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: output.txt
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/a6c56418/attachment.txt

“valgrind --tool=memcheck --leak-check=full --show-reachable=yes
–log-file=output.txt ./Testing”

–show-reachable might be overkill, some of the leaks are by design
(where the code just relies on the application quitting to cleanup),
which some might find questionable, but are nonetheless working
"correctly".

The “definitely lost” are more worrying (and are thankfully fewer),
but some are just out of our control, such as those in XCreateIC (I
think we call XDestroyIC correctly, if that doesn’t clean it up,
that’s pretty much in libX11’s hands).

When using Valgrind on SDL, you should build your own SDL with debug
symbols enabled (make sure it’s compiled with at least -g). The second
one before your “Other leaks msgs” line seems legit, for example, but
is missing too much information to be helpful.On Tue, May 19, 2009 at 3:17 PM, Bruno Adami <a_j_bruno at hotmail.com> wrote:

–
http://pphaneuf.livejournal.com/

Here is the others logs I removed from output.txt

(Attached 11-27)_________________________________________________________________
Emoticons e Winks super diferentes para o Messenger. Baixe agora, ? gr?tis!
http://specials.br.msn.com/ilovemessenger/pacotes.aspx
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: 11-27.txt
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/ac661a3b/attachment.txt

Here is the last 28-44

(Attached 28-44)_________________________________________________________________
Emoticons e Winks super diferentes para o Messenger. Baixe agora, ? gr?tis!
http://specials.br.msn.com/ilovemessenger/pacotes.aspx

I forgot to attach the file :slight_smile:

28-44_________________________________________________________________
Descubra todas as novidades do novo Internet Explorer 8
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: 28-44.txt
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090519/5939836d/attachment.txt

When I use valgrind to check for memory errors I got 53 leaks detected!

We need to add something like this to SDL:

if (valgrind_running())
printf(“Xlib has memory leaks, it’s not SDL’s fault.\n”);

–ryan.