From 4e60a749e9f45aa94a31715e99b7306937dcb0a8 Mon Sep 17 00:00:00 2001 From: papush! Date: Thu, 24 Mar 2022 15:25:18 +0100 Subject: [PATCH] fixed memory leaks --- src/dihedral_angles_filter.cc | 1 + src/main.cc | 4 +++- src/remove_external_cells_filter.cc | 1 + src/surface_points_filter.cc | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dihedral_angles_filter.cc b/src/dihedral_angles_filter.cc index 9040ad7..88c28d6 100644 --- a/src/dihedral_angles_filter.cc +++ b/src/dihedral_angles_filter.cc @@ -72,6 +72,7 @@ vtkTypeBool DihedralAnglesFilter::RequestData( i += 6; } + it->Delete(); AverageMinDegrees /= input->GetNumberOfCells(); AverageMinDegrees = AverageMinDegrees * 180. / 3.141592653589793; MinMinDegrees = MinMinDegrees * 180. / 3.141592653589793; diff --git a/src/main.cc b/src/main.cc index efbebcc..baaaa5e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -37,7 +37,7 @@ #include -vtkSmartPointer readerFromFileName(const char *fileName) { +vtkAlgorithm *readerFromFileName(const char *fileName) { std::string extension = vtksys::SystemTools::GetFilenameLastExtension(fileName); if (extension == ".vtk") { @@ -148,5 +148,7 @@ int main(int argc, char **argv) { renderWindow->Render(); renderWindowInteractor->Start(); #endif + tetMeshReader->Delete(); + polyMeshReader->Delete(); return EXIT_SUCCESS; } diff --git a/src/remove_external_cells_filter.cc b/src/remove_external_cells_filter.cc index 55dafa2..6fb5c53 100644 --- a/src/remove_external_cells_filter.cc +++ b/src/remove_external_cells_filter.cc @@ -60,6 +60,7 @@ vtkTypeBool RemoveExternalCellsFilter::RequestData( outCells->InsertNextCell(it->GetPointIds()); } } + it->Delete(); output->SetCells(VTK_TETRA, outCells); output->SetPoints(tetMesh->GetPoints()); diff --git a/src/surface_points_filter.cc b/src/surface_points_filter.cc index 6b73428..d950367 100644 --- a/src/surface_points_filter.cc +++ b/src/surface_points_filter.cc @@ -72,6 +72,7 @@ vtkTypeBool SurfacePointsFilter::RequestData( } } } + it->Delete(); surfacePoints->Allocate(surfacePointsSet.size()); for (const vtkIdType &id : surfacePointsSet) { surfacePoints->InsertNextValue(id);