[ros-users] Patch for memory leak in frame_common

Daniel Maturana dimatura at gmail.com
Tue Feb 1 22:55:32 UTC 2011


Hi,
I'm using vslam and noticed a memory leak in
FrameProc::setStereoPoints. The method has a return path which fails
to release an allocated FrameStereo object. Since the FrameStereo
object has an image-sized buffer and this occurs on every frame it
quickly adds up to hundreds of megabytes. I checked out the last
version of frame.cpp from
https://code.ros.org/svn/ros-pkg/stacks/vslam/tags/unstable/frame_common/src/frame.cpp
and the problem is still there. I attach a diff with the fix.
best,
Daniel Maturana

Index: frame.cpp
===================================================================
--- frame.cpp	(revision 35681)
+++ frame.cpp	(working copy)
@@ -34,6 +34,7 @@


 #include <frame_common/frame.h>
+#include <pcl/common/common.h>

 using namespace Eigen3;
 using namespace std;
@@ -264,7 +265,10 @@
           frame.goodPts[i] = false;
       }

-    if (!setPointCloud) return;
+    if (!setPointCloud) {
+      delete st;
+      return;
+    }

     // convert disparities and image to point cloud with luminance/RGB
     double cx = frame.cam.cx;



More information about the ros-users mailing list