PointCloudLibrary / PointCloudLibrary/pcl

Memory leak when using pcl::visualization::PCLVisualizer with interactor

Open
#2,225 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Your Environment

I have two environments, one with Linux and the other one with Windows.
Windows environment:

  • Operating System and version: Windows 7 x64 Professional
  • Compiler: Microsoft Visual Studio 2017 toolset v140
  • PCL Version: 1.8.0

Linux environment:

  • Operating System and version: xubuntu 16.10 x64
  • Compiler: g++ 5.2
  • PCL Version: 1.8.0

Context

I want to display point clouds and save them to images. I want to be able to rotate, scale and move clouds while displaying them.

Expected Behavior

Every time PCLVisualizer is created and initialized it consumes some RAM and GPU RAM. It has to be freed after calls to close and release.

Current Behavior

Despite calling close on PCLVisualizer and release on a shared pointer holding it most of the allocated memory is not released.

Code to Reproduce

Possible Solution

This is definetely related to reference counting of VTK objects and a cyclic strong reference chain created in createInteractor. When interactor is not created no memory is leaked, but visualizer is not usable.

I tried to clear the reference cycle in destructor of PCLVisualizer. It worked on Windows. But on Linux I get BadWindow error in console and application terminates. I added the following to if (interactor_ != NULL) block of destructor

interactor_->SetRenderWindow(nullptr);
interactor_->SetInteractorStyle(nullptr);

Could you tell what else needs to be done so that X Server would not report an error?

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::visualization::PCLVisualizer, focusing on createInteractor and the destructor's interactor_ cleanup. Reproduce repeated visualizer creation and release on the reported Linux and Windows environments, then trace the VTK reference cycle and the BadWindow failure. Done means the visualizer can be created, used, closed, and released without retained memory or X Server errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.