Skip to content

Fix memory leaks and a mismatched new / delete[] - #56

Merged
valette merged 1 commit into
valette:masterfrom
JensMunkHansen:fix-memory-leaks
Nov 5, 2026
Merged

valette merged 1 commit into
valette:masterfrom
JensMunkHansen:fix-memory-leaks

Conversation

@JensMunkHansen

Copy link
Copy Markdown
Contributor

Found with valgrind --leak-check=full on ACVD, ACVDQ, ACVDP and ACVDQP; all four now report 0 bytes definitely lost.

  • vtkQEMetricForClustering never freed Items. It is now initialised to 0 and deleted in the destructor, as vtkIsotropicMetricForClustering does.
  • vtkSinglePolynomialMeasure allocated SecondMember[i] with new double and freed it with delete []. Its matrices and Quadric are now contiguous std::vector / array storage with row pointers for SolveLeastSquares.
  • vtkThreadedClustering::ComputeEdgesLayout never freed its EdgesLayout array; it is now a std::vector moved into EdgesProcess.
  • vtkSurface::WriteToFile never deleted its writer.

Found with valgrind --leak-check=full on ACVD, ACVDQ, ACVDP and ACVDQP;
all four now report 0 bytes definitely lost.

- vtkQEMetricForClustering never freed Items. It is now initialised to 0
  and deleted in the destructor, as vtkIsotropicMetricForClustering does.
- vtkSinglePolynomialMeasure allocated SecondMember[i] with new double and
  freed it with delete []. Its matrices and Quadric are now contiguous
  std::vector / array storage with row pointers for SolveLeastSquares.
- vtkThreadedClustering::ComputeEdgesLayout never freed its EdgesLayout
  array; it is now a std::vector moved into EdgesProcess.
- vtkSurface::WriteToFile never deleted its writer.
@JensMunkHansen

Copy link
Copy Markdown
Contributor Author

This is just the leaks. Could next fix the missing determinism. I did this while also switching to a more efficient threading backend. Let me know if you want the determinism next. Then we could change the filter to properly do in-place operations, the pipeline have support for that. Finally, if you want, SMPTools and modern typed interface avoids a lot of virtual calls, which translates to performance.

@valette
valette merged commit 860a1d6 into valette:master Nov 5, 2026
6 checks passed
@valette

valette commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants