Memory leak in QVTK widget and PCL visualizer

I m using Ubuntu 20.04 with Qt5.12 for developing a QT project which uses a QVTK widget to display a 3D PCL visualiser. I m facing memory leak issues after defining the visualiser and vtk widget relationship. The header file contents are as follows:

class SiLS : public QMainWindow


    SiLS(QWidget *parent = nullptr);


    Ui::SiLS *ui;
    pcl::visualization::PCLVisualizer::Ptr viewer_3D;

The cpp file contents are as follows:

SiLS::SiLS(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::SiLS)

    viewer_3D.reset (new pcl::visualization::PCLVisualizer ("viewer_3D", false));
    viewer_3D->setupInteractor (ui->qvtkWidget->GetInteractor (), ui->qvtkWidget->GetRenderWindow ());

    delete ui;

Only these 3 lines of code in the constructor is giving lot of memory leak issues. How to destruct the qvtkwidget properly?

Thanks for reporting the problem.

What do you exactly mean by “memory leaks” ? Are you referring to issues discovered using tool like memcheck, or are these reported as vtkDebugLeaks ?

To better understand how the different objects are created, could you share a like to a minimal GitHub project allowing to reproduce the problem ? The project would include relevant source files, a CMakeLists.txt, a detailing how to download and build the dependencies (VTK, pcl, …)

Looking at the snippet you shared, it is unclear how the Ui::SiLS object is implemented.

Memory leak issues were generated by valgrind which is present in Qt Creator. I have committed the project files to Github here. Readme file shows detailed installation setup.

One of the issue trace back is as shown below:

How to debug in these lib files?