Page MenuHomePhabricator

Memory-Leak in mitk::Surface
Closed, ResolvedPublic

Description

The mitk::Surface::Graft(newSurface*) function has a memory leak:

The std::vector<vtkPolyData*> m_PolyDatas is cleared and afterward the polydatas of the new surface are filled into it.
However the new PolyDatas are created like this: vtkPolyData::New().
If there are already polydata inside of m_Polydatas, these objects will never be deleted.

Another issue is the mitkSurfaceToSurfaceFilter:

If you call SetNthInput(idx, obj) for all existing inputs a new output is generated, i.e. mitk::Surface::Graft is called.
In case of many inputs the memory leak / performance becomes critical.

Event Timeline

Since this is a critical issue I wrote the change request in advance. The branch with the fixes will follow

User fetzer has pushed new remote branch:

bug-18688-memory-leak-in-surface

[a298f8]: Merge branch 'bug-18688-memory-leak-in-surface'

Merged commits:

2015-01-29 13:27:58 Andreas Fetzer [c1df45]
cosmetic changes


2015-01-29 09:51:36 Andreas Fetzer [dde818]
Enhanced test for SurfaceToSurfaceFilter

Replaced std::couts with mitkTestingMacros


2015-01-29 09:50:51 Andreas Fetzer [55d5de]
Fixed recreation/reallocation of all outputs if a new input was added.

Now there are two different functions:

CreateOutputForInput(idx) which only creates an output for the input at [idx]
CreateOutputsForAllInputs() which implements the previous behaviour and recreates all outputs.


2015-01-29 09:43:50 Andreas Fetzer [24407a]
Fixed memory leak in mitkSurface

The internal vector of vtkPolyDatas stores now vtkSmartPointers.

[9416b7]: Merge branch 'bug-18688-memory-leak-in-surface'

Merged commits:

2015-01-29 14:03:30 Andreas Fetzer [ba4891]
COMP Fixed wrong usage of SurfaceToSurfaceFilter

User fetzer has pushed new remote branch:

bug-18688-fix-leak-in-surface

[c597c6]: Merge branch 'bug-18688-memory-leak-in-surface'

Merged commits:

2015-01-29 17:11:06 Andreas Fetzer [4b3fc8]
COMP Fixed another leak in surface