Widelands is leaking memory

Bug #1438611 reported by Hans Joachim Desserud
8
This bug affects 1 person
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-leak-kinds=all

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)

Tags: memory

Related branches

Changed in widelands:
importance: Undecided → Medium
Revision history for this message
Jens Beyer (qcumber-some) wrote :

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.

Revision history for this message
Jens Beyer (qcumber-some) wrote :

I merged the AnimationManager destructor change.

Keeping the topic open until it is decided that nothing needs to be done for b19 anymore.

Changed in widelands:
milestone: none → build19-rc1
status: New → Triaged
Revision history for this message
SirVer (sirver) wrote :

I profiled in the attached branch at r7721 and I found no major memory leak right now, I think we are good for now.

Changed in widelands:
assignee: nobody → SirVer (sirver)
status: Triaged → In Progress
SirVer (sirver)
Changed in widelands:
status: In Progress → Fix Released
assignee: SirVer (sirver) → nobody
status: Fix Released → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.