Free memory and delete links of VTKSmartPointer Polydata


In my mesh, there are 642473 cells and 1275549 points.
I want to replace cell of the mesh and after replacement, I want to reassign the mesh on the same name. But before reassign how can I free the memory and delete all the links of the previous one.

Using Below code, it’s not freeing the mesh and I am getting the “Killed” message.

auto result = ReplaceCells(mesh,i);
vtkSmartPointer mesh=vtkSmartPointer::New();
mesh = std::get<0>(result);

Thanks in advance.

This is a VTK-related question, and should be posted on VTK discourse.

Sorry bout that.