From 04bb83dab36b4ba5ab9fec75b09de76e7404dcb1 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 1 Sep 2019 22:48:16 +0200 Subject: [PATCH] PointCloud display: fix memory leak in case of constant /clock (#1412) --- src/rviz/default_plugin/point_cloud_common.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rviz/default_plugin/point_cloud_common.cpp b/src/rviz/default_plugin/point_cloud_common.cpp index 711f9dd576..f260120537 100644 --- a/src/rviz/default_plugin/point_cloud_common.cpp +++ b/src/rviz/default_plugin/point_cloud_common.cpp @@ -532,7 +532,7 @@ void PointCloudCommon::update(float wall_dt, float ros_dt) // and put them into obsolete_cloud_infos, so active selections // are preserved - ros::Time now = ros::Time::now(); + auto now_sec = ros::Time::now().toSec(); // if decay time == 0, clear the old cloud when we get a new one // otherwise, clear all the outdated ones @@ -540,7 +540,7 @@ void PointCloudCommon::update(float wall_dt, float ros_dt) boost::mutex::scoped_lock lock(new_clouds_mutex_); if ( point_decay_time > 0.0 || !new_cloud_infos_.empty() ) { - while( !cloud_infos_.empty() && now.toSec() - cloud_infos_.front()->receive_time_.toSec() > point_decay_time ) + while( !cloud_infos_.empty() && now_sec - cloud_infos_.front()->receive_time_.toSec() >= point_decay_time ) { cloud_infos_.front()->clear(); obsolete_cloud_infos_.push_back( cloud_infos_.front() ); @@ -581,7 +581,7 @@ void PointCloudCommon::update(float wall_dt, float ros_dt) V_CloudInfo::iterator next = it; next++; // ignore point clouds that are too old, but keep at least one - if ( next != end && now.toSec() - cloud_info->receive_time_.toSec() > point_decay_time ) { + if ( next != end && now_sec - cloud_info->receive_time_.toSec() >= point_decay_time ) { continue; }