In your example, im_left is owned by left_bridge and should not be released. However any images you create yourself do need to be released. The memory leak is from not releasing "test".<br><br>The original <a href="http://opencv.willowgarage.com/documentation/c/index.html">OpenCV C API</a> works with IplImage's. The new <a href="http://opencv.willowgarage.com/documentation/cpp/index.html">C++ API</a> cv::Mat is easier to use and avoids having to release memory manually.<br>
<br>cv_bridge only uses IplImage because it predates the OpenCV C++ API. The next revision of cv_bridge will likely use cv::Mat, precisely to avoid this sort of confusion.<br><br>Patrick<br><br><div class="gmail_quote">On Sat, May 22, 2010 at 4:54 PM, chriss lei <span dir="ltr"><<a href="mailto:lei.chriss@gmail.com">lei.chriss@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hello Radu,<br>
<br>
I'm well aware of using cvReleaseImage..<br>
Memory leak happens even if I use a single function on IplImage converted<br>
from sensor_msgs.<br>
Here's my callback function to illustrate. Usage of cvCopy here introduces<br>
memory blowup problem.<br>
<br>
void callback(const sensor_msgs::CameraInfo::ConstPtr& info,<br>
                            const sensor_msgs::ImageConstPtr& left,<br>
                            const stereo_msgs::DisparityImageConstPtr& disparity_msg)<br>
        {<br>
<br>
                im_left = left_bridge.imgMsgToCv(left, "passthrough");<br>
<br>
                disp_bridge.fromImage(disparity_msg->image, "passthrough");<br>
                dispImg = disp_bridge.toIpl();<br>
<br>
                cvShowImage("left", im_left);<br>
<br>
                IplImage* test = NULL;<br>
                test = cvCreateImage(cvGetSize(dispImg), dispImg->depth, 1);<br>
                cvCopy(dispImg, test);<br>
                cvShowImage("disp", test);<br>
       }<br>
<br>
Also, I'm not supposed to deallocate any IplImages that are converted from<br>
sensor_msgs as described in cvBridge tutorial.<br>
Is there a way to use opencv functions on IplImages and not use cv::Mat ?<br>
<br>
--<br>
View this message in context: <a href="http://ros-users.122217.n3.nabble.com/cvBridge-opencv-memory-leak-problem-tp837144p837162.html" target="_blank">http://ros-users.122217.n3.nabble.com/cvBridge-opencv-memory-leak-problem-tp837144p837162.html</a><br>

Sent from the ROS-Users mailing list archive at Nabble.com.<br>
<br>
------------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@lists.sourceforge.net">ros-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/ros-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/ros-users</a><br>
<div><div></div><div class="h5">_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</div></div></blockquote></div><br>