SDL Memory Leaks is not only because Xlib issue?

Hi SDL developers,

I am a newbie in the SDL world, so I played around the example of libsdl
1.2, such as testwin.c
http://hg.libsdl.org/SDL/file/bbfb41c13a87/test/testwin.c
It shown a SDL window, delayed about 92 milliseconds, then quit quietly.

But valgrind ./testwin
==10240==
==10240== HEAP SUMMARY:
==10240== in use at exit: 34,729 bytes in 458 blocks
==10240== total heap usage: 3,604 allocs, 3,146 frees, 510,344 bytes
allocated
==10240==
==10240== LEAK SUMMARY:
==10240== definitely lost: 74 bytes in 5 blocks
==10240== indirectly lost: 536 bytes in 12 blocks
==10240== possibly lost: 0 bytes in 0 blocks
==10240== still reachable: 34,119 bytes in 441 blocks
==10240== suppressed: 0 bytes in 0 blocks
==10240== Rerun with --leak-check=full to see details of leaked memory
==10240==
==10240== For counts of detected and suppressed errors, rerun with: -v
==10240== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

There was 33KB not released, I google with “SDL memory leak”, some
people said it might be Xlib issue: Xlib has some small allocations it
fails to free http://forums.libsdl.org/viewtopic.php?p=28387
http://forums.libsdl.org/viewtopic.php?p=28387&sid=0dfecd58e2904345febcd1bdb6fa695d

Then I wrote a Xlib test case MyXWin
https://github.com/xiangzhai/drummer/blob/master/src/myxwin.cpp
It supported double buffering, AlwaysOnTop feature, then valgrind ./test_x
==10390==
==10390== HEAP SUMMARY:
==10390== in use at exit: 344 bytes in 2 blocks
==10390== total heap usage: 125 allocs, 123 frees, 51,584 bytes allocated
==10390==
==10390== LEAK SUMMARY:
==10390== definitely lost: 320 bytes in 1 blocks
==10390== indirectly lost: 0 bytes in 0 blocks
==10390== possibly lost: 0 bytes in 0 blocks
==10390== still reachable: 24 bytes in 1 blocks
==10390== suppressed: 0 bytes in 0 blocks
==10390== Rerun with --leak-check=full to see details of leaked memory
==10390==
==10390== For counts of detected and suppressed errors, rerun with: -v
==10390== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 3 from 3)

There was only 0.33KB not released, so SDL Memory Leaks is not only
because Xlib issue?
Please someone give me some advice, thanks a lot!

Best Regards,

Leslie

If you “==10240== Rerun with --leak-check=full to see details of
leaked memory” valgrind will tell you which malloc was not being
freed.On Thu, Oct 17, 2013 at 3:49 AM, Leslie Zhai wrote:

Hi SDL developers,

I am a newbie in the SDL world, so I played around the example of libsdl
1.2, such as testwin.c
http://hg.libsdl.org/SDL/file/bbfb41c13a87/test/testwin.c
It shown a SDL window, delayed about 92 milliseconds, then quit quietly.

But valgrind ./testwin
==10240==
==10240== HEAP SUMMARY:
==10240== in use at exit: 34,729 bytes in 458 blocks
==10240== total heap usage: 3,604 allocs, 3,146 frees, 510,344 bytes
allocated
==10240==
==10240== LEAK SUMMARY:
==10240== definitely lost: 74 bytes in 5 blocks
==10240== indirectly lost: 536 bytes in 12 blocks
==10240== possibly lost: 0 bytes in 0 blocks
==10240== still reachable: 34,119 bytes in 441 blocks
==10240== suppressed: 0 bytes in 0 blocks
==10240== Rerun with --leak-check=full to see details of leaked memory
==10240==
==10240== For counts of detected and suppressed errors, rerun with: -v
==10240== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

There was 33KB not released, I google with “SDL memory leak”, some people
said it might be Xlib issue: Xlib has some small allocations it fails to
free http://forums.libsdl.org/viewtopic.php?p=28387

Then I wrote a Xlib test case MyXWin
https://github.com/xiangzhai/drummer/blob/master/src/myxwin.cpp
It supported double buffering, AlwaysOnTop feature, then valgrind ./test_x
==10390==
==10390== HEAP SUMMARY:
==10390== in use at exit: 344 bytes in 2 blocks
==10390== total heap usage: 125 allocs, 123 frees, 51,584 bytes allocated
==10390==
==10390== LEAK SUMMARY:
==10390== definitely lost: 320 bytes in 1 blocks
==10390== indirectly lost: 0 bytes in 0 blocks
==10390== possibly lost: 0 bytes in 0 blocks
==10390== still reachable: 24 bytes in 1 blocks
==10390== suppressed: 0 bytes in 0 blocks
==10390== Rerun with --leak-check=full to see details of leaked memory
==10390==
==10390== For counts of detected and suppressed errors, rerun with: -v
==10390== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 3 from 3)

There was only 0.33KB not released, so SDL Memory Leaks is not only because
Xlib issue?
Please someone give me some advice, thanks a lot!

Best Regards,

Leslie


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org