Memory leaks in AStarPathfinder

Bug #566054 reported by Ferdinand Majerech
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Catom
In Progress
Low
Unassigned

Bug Description

According to Valgrind, there are a few memory leaks in AStarPathfinder that leak memory
_at the end of catom run_, which suggests Catom doesn't delete everything it allocated at its destruction.
The memory that is not dealocated is allocated at lines 55 (setTarget) and 281(addSuccessor).
I tried to fix this, but failed horribly as I do't understand the pathfinder code.

After a ~30 second run involving about 10 move orders, the leaks are as follows:

==24434== 7,536 (960 direct, 6,576 indirect) bytes in 20 blocks are definitely lost in loss record 14 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x437D11: catom::pathfinder::AStarPathfinder::setTarget(catom::math::Vector3 const&) (AStarPathfinder.cpp:55)
==24434== by 0x4363B7: catom::game::Unit::move(catom::math::Vector3 const&) (Unit.cpp:92)
==24434== by 0x43AF4C: catom::action::MoveUnit::operator()(catom::game::Game*, unsigned int, unsigned int) (MoveUnit.cpp:43)

and:

==24434== 96 bytes in 2 blocks are indirectly lost in loss record 6 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438E7E: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 192 bytes in 4 blocks are indirectly lost in loss record 7 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438F4C: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 240 bytes in 5 blocks are indirectly lost in loss record 8 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438CE6: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 624 bytes in 13 blocks are indirectly lost in loss record 9 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438C8C: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 912 bytes in 19 blocks are indirectly lost in loss record 10 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438D49: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 1,248 bytes in 26 blocks are indirectly lost in loss record 11 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438EEA: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 1,584 bytes in 33 blocks are indirectly lost in loss record 12 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438DAC: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)
==24434==
==24434== 1,680 bytes in 35 blocks are indirectly lost in loss record 13 of 15
==24434== at 0x4C27CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==24434== by 0x438FC5: catom::pathfinder::AStarPathfinder::addSuccessor(catom::math::Vector3 const&) (AStarPathfinder.cpp:281)
==24434== by 0x438E18: catom::pathfinder::AStarPathfinder::getSuccessors(catom::pathfinder::AStarPathfinder::Node*) (AStarPathfinder.cpp:259)
==24434== by 0x4380A6: catom::pathfinder::AStarPathfinder::search() (AStarPathfinder.cpp:120)
==24434== by 0x4361B0: catom::game::Unit::update() (Unit.cpp:60)
==24434== by 0x41FFAE: main (Catom.cpp:99)

Changed in catom:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Mak Nazečić-Andrlon (owlberteinstein)
Changed in catom:
status: Confirmed → In Progress
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.