Widelands is leaking memory
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Medium
|
Unassigned |
Bug Description
I remember people worked a bit on reducing memory leaks before build18 was released. At the time we got it most of it cleaned up. Widelands would still leak a small amount of memory, but it was something around 800 bytes and would happen even if you only opened the game and immediately quit from the main menu. Playing a game for five minutes did not seem to impact this number so it appeared constant.
Since then there's been all sorts of code changes, so I thought I'd take a look and see what the current state is, and Widelands has started to leak memory again. My test ("benchmark"):
1. Run $ valgrind --leak-check=full ./widelands
2. Start a new game, pick Crater (a nice, small map)
3. Built a lumberjack, waited for it to finish and the lumberjack to chop down and bring back the first log.
(3B. The enemy AI presumably did something)
4. Quit and exit the game.
Outcome:
==4654== LEAK SUMMARY:
==4654== definitely lost: 725,718 bytes in 4,233 blocks
==4654== indirectly lost: 20,324,403 bytes in 90,867 blocks
==4654== possibly lost: 16,554,779 bytes in 1,271 blocks
==4654== still reachable: 96,024 bytes in 931 blocks
==4654== suppressed: 0 bytes in 0 blocks
==4654== Reachable blocks (those to which a pointer was found) are not shown.
==4654== To see them, rerun with: --leak-check=full --show-
If I remember the valgring lingo, definitely lost is the number we need to watch. It's not a large number, but would presumably grow if the game had continued. I would appreciate it if someone could look into this and see whether it is possible resolve these leaks.
(Note that some of the stacktraces seem to be deep down in my graphics driver, so I don't know whether that is something we can evade, but several of them are in the WL-code)
Related branches
- TiborB: Approve
-
Diff: 33 lines (+9/-0)2 files modifiedsrc/graphic/animation.cc (+6/-0)
src/graphic/animation.h (+3/-0)
- GunChleoc: Approve
- Tino: Approve
-
Diff: 539 lines (+140/-142)6 files modifiedsrc/graphic/rendertarget.cc (+92/-82)
src/graphic/rendertarget.h (+8/-6)
src/graphic/text/font_io.cc (+1/-1)
src/logic/map_objects/world/world.cc (+2/-2)
src/ui_basic/table.cc (+5/-19)
src/ui_fsmenu/loadgame.cc (+32/-32)
Changed in widelands: | |
importance: | Undecided → Medium |
Changed in widelands: | |
status: | In Progress → Fix Released |
assignee: | SirVer (sirver) → nobody |
status: | Fix Released → Fix Committed |
Changed in widelands: | |
status: | Fix Committed → Fix Released |
Just did the mentioned sequence with the lumberjack.
Biggest "definitely lost" item was the AnimationManager which is missing a Destructor which cleans the m_animations vector.