Ask Your Question
0

Memory Leak in transformPointCloud ?

asked 2011-12-13 07:41:54 -0600

John Hoare gravatar image

updated 2014-01-28 17:11:00 -0600

ngrennan gravatar image

I've written a quick node which will take as input a pointcloud and will transform it and republish it at another arbitrary TF location. This node seems to be ballooning up and eating all of the memory very quickly, It doesn't look like there is a memory leak in my code, but I could be wrong. Is anybody else having problems with this function?

Here's a code snippit from the callback in question (this code was largely modified from The Pointcloud to Image utility in pcl_ros:

void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud)
{
   sensor_msgs::PointCloud2Ptr outp = sensor_msgs::PointCloud2Ptr(new sensor_msgs::PointCloud2);
  if ((cloud->width * cloud->height) == 0)
    return; //return if the cloud is not dense!
  while(!pcl_ros::transformPointCloud(transform_to_, *cloud, *outp, listener_)){
    ros::Duration(0.1).sleep();
  }
  pub_.publish (outp); //publish our cloud image
}

It looks like it really starts to leak memory once its in the while() loop.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-12-13 08:13:19 -0600

Mac gravatar image

Is it, in fact, publishing the transformed point clouds?

One really easy way to eat up memory is for your callback to be too slow; in this case, the callback queue will start to eat memory like crazy. It doesn't take very many pointclouds for that to be a problem.

edit flag offensive delete link more

Comments

If it gets stuck in the loop it is not publishing point clouds. However, I do set the queue size to be very small (like 5) and so it should not endlessly grow in size, right?
John Hoare gravatar imageJohn Hoare ( 2011-12-13 09:15:28 -0600 )edit
The amount of memory it eats should be bounded by the queue size, yes. However, if you aren't actually publishing clouds, that's your real problem; something about your transforms is messed up (I can't quite tell from your comment if clouds actually get published).
Mac gravatar imageMac ( 2011-12-14 02:44:09 -0600 )edit
Sorry. In the normal circumstances, yes it does publish the pointcloud. When it is spinning in the while loop however, nothing gets published. It is in the "when nothing gets published" case where the memory usage seems to get out of control.
John Hoare gravatar imageJohn Hoare ( 2011-12-14 05:43:42 -0600 )edit
When you're in the while loop you're still receiving data but not publishing it. Which means that the receiving side is allocating memory to queue up incoming messages while the sending side is blocked and not releasing memory at the same time, thus your memory usage grows.
tfoote gravatar imagetfoote ( 2012-01-02 06:27:24 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-12-13 07:41:54 -0600

Seen: 726 times

Last updated: Dec 13 '11