Hello,

I've decided to get a look at the memory handling in worms, and check
typical initialization problems, using valgrind [1] 3.1.0 (Debian) tool
named memcheck [2], which I find very effective, at least it is 100%
when I code. So far, I just loaded the game, let it display the menu
then exit.

Well, it seems there are lots of leaks and uninitialized data access,
mainly due to autoFree not set most of the time in Surface objects,
which I find rather strange though. This ends up with those typical results:

==28256== 13,959,556 bytes in 94 blocks are possibly lost in loss record
139 of 140
==28256==    at 0x401B41A: malloc (vg_replace_malloc.c:149)
==28256==    by 0x40F9DAB: SDL_CreateRGBSurface (in
/usr/lib/libSDL-1.2.so.0.7.2)
==28256==    by 0x402A7E9: rotozoomSurfaceXY (in
/usr/lib/libSDL_gfx.so.4.9.0)
==28256==    by 0x8060E7C: Wormux::Surface::RotoZoomXY(double, double,
double, int) (surface.cpp:212)
==28256==    by 0x8063210: Sprite::EnableFlippingCache() (sprite.cpp:210)
==28256==    by 0x80B1DCB: Skin::LoadManySkins(xmlpp::Element*,
Profile*) (skin.cpp:165)
==28256==    by 0x80B2349: Skin::Charge(std::string const&, std::string
const&) (skin.cpp:115)
==28256==    by 0x80B2674: LoadOneSkin(std::string const&, std::string
const&) (skin.cpp:280)
==28256==
==28256==
==28256== 14,177,432 bytes in 1,833 blocks are indirectly lost in loss
record 140 of 140
==28256==    at 0x401B41A: malloc (vg_replace_malloc.c:149)
==28256==    by 0x40F9DAB: SDL_CreateRGBSurface (in
/usr/lib/libSDL-1.2.so.0.7.2)
==28256==    by 0x402A7E9: rotozoomSurfaceXY (in
/usr/lib/libSDL_gfx.so.4.9.0)
==28256==    by 0x8060E7C: Wormux::Surface::RotoZoomXY(double, double,
double, int) (surface.cpp:212)
==28256==    by 0x8063210: Sprite::EnableFlippingCache() (sprite.cpp:210)
==28256==    by 0x80B1DCB: Skin::LoadManySkins(xmlpp::Element*,
Profile*) (skin.cpp:165)
==28256==    by 0x80B2349: Skin::Charge(std::string const&, std::string
const&) (skin.cpp:115)
==28256==    by 0x80B2674: LoadOneSkin(std::string const&, std::string
const&) (skin.cpp:280)

OK, I think I've already pasted a huge chunk so I let you examine more
in depth the log available at [3]. I don't think it is unreadable, but
if you need help on reading the log, I can try.

Best regards,
Kurosu

[1] http://valgrind.org/
[2] http://valgrind.org/docs/manual/mc-manual.html
[3] http://kurosu.free.fr/wormux/wormux.log.bz2

Répondre à