Skip to content

Commit

Permalink
Merge pull request leggedrobotics#318 from leggedrobotics/fix/memory_…
Browse files Browse the repository at this point in the history
…leak

One line of code fixes everything!
  • Loading branch information
mbjelonic committed May 3, 2021
2 parents d28f10a + 2996594 commit 36a4c9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions darknet_ros/launch/darknet_ros_valgrind.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<launch>

<!-- Launch darknet ros with gdb launch prefix -->
<!-- Check the following links: -->
<!-- https://stackoverflow.com/questions/13500541/valgrind-how-to-force-it-to-generate-heap-summary-without-terminating-process -->
<!-- https://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver-commandhandling -->
<include file="$(find darknet_ros)/launch/darknet_ros.launch">
<arg name="launch_prefix" value="valgrind --leak-check=full --show-leak-kinds=all --verbose --vgdb=yes --vgdb-error=0"/>
</include>

</launch>
1 change: 1 addition & 0 deletions darknet_ros/src/YoloObjectDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ void* YoloObjectDetector::fetchInThread() {
{
boost::shared_lock<boost::shared_mutex> lock(mutexImageCallback_);
CvMatWithHeader_ imageAndHeader = getCvMatWithHeader();
free_image(buff_[buffIndex_]);
buff_[buffIndex_] = mat_to_image(imageAndHeader.image);
headerBuff_[buffIndex_] = imageAndHeader.header;
buffId_[buffIndex_] = actionId_;
Expand Down

0 comments on commit 36a4c9c

Please sign in to comment.