Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PointCloud display: fix memory leak in case of constant /clock #1412

Merged
merged 2 commits into from
Sep 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/rviz/default_plugin/point_cloud_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,15 @@ 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
{
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() );
Expand Down Expand Up @@ -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;
}

Expand Down