Memory leak in PCL visualizer and QVTK widget

139 Views Asked by At

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
{
    Q_OBJECT

public:

    SiLS(QWidget *parent = nullptr);
    ~SiLS();

private:

    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)
{
    ui->setupUi(this);

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

SiLS::~SiLS()
{
    delete ui;
}

Only these 3 lines of code in constructor is giving lot of memory leak issues. Following screenshot shows few of the leaks identified by valgrind in Qt creator. enter image description here

SiLS.cpp:10:0 represents the following line in cpp file:

viewer_3D.reset (new pcl::visualization::PCLVisualizer ("viewer_3D", false));

0

There are 0 best solutions below