PointCloudLibrary / PointCloudLibrary/pcl

Saving PCD files consumes memory after writing the file

Open
#1,841 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs: code review
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

⚠️ This is a issue tracker, please use our mailing list for questions: www.pcl-users.org. ⚠️

Your Environment

  • Operating System and version: Jetson TX1 Ubuntu 16.04
  • Compiler: 5.4.0
  • PCL Version: 1.8 (from git)

Current Behavior

Using pcl::io::savePCDFile() consumes as much RAM as the filesize. As I am running this in a loop, this quickly consumes all memory until the program crashes. The memory is freed when I delete the files from disk while the program is running, and some of it is freed when I terminate the program. This occurs with all methods of saving PCD files.

Expected Behavior

Saving PCD files to disk should not consume all the RAM even after the file has been written

Code to Reproduce

    int savePersonCluster(PointCloud::ConstPtr cloud, pcl::people::PersonCluster<PointT> cluster, std::string uuid) {
        PointCloud::Ptr tmp(new PointCloud);
        pcl::CropBox<PointT> crop;
        crop.setInputCloud(cloud);
        crop.setMin(Eigen::Vector4f(cluster.getMin().x(), cluster.getMin().y(), cluster.getMin().z(), 0));
        crop.setMax(Eigen::Vector4f(cluster.getMax().x(), cluster.getMax().y(), cluster.getMax().z(), 0));
        crop.filter(*tmp);
        tmp->header.frame_id = cloud->header.frame_id;
        std::stringstream ss;
        ss << cluster_save_path << "/" << uuid << std::string(".pcd");
        if (save_person_clusters) pcl::io::savePCDFileBinaryCompressed(ss.str(), *tmp);
        return tmp->points.size();
    }

Setting save_person_clusters to false does not consume any memory.

Context

I am pulling pointclouds from a Kinect v2 using iai_kinect2 using ROS.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at pcl::io::savePCDFileBinaryCompressed, then reproduce the reported loop on the Jetson TX1 environment using the provided savePersonCluster example. Trace memory ownership during repeated PCD writes and verify that repeated saves no longer accumulate RAM; add or run a regression test if the relevant test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.