Page MenuHomePhabricator

Memory leaks from wrong usage of vtkSmartPointer
Closed, ResolvedPublic

Description

More by accident I noticed that there are several places in MITK where people try to use VTK smart pointers (http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers) but do so in a wrong or unusual way.

Some points just assume that assigning vtkType::New to a smart pointer will work, others don't assume that and call Delete() later. Both does not go with the idea of smart pointers. The (mostly) correct way is to create objects via vtkSmartPointer<vtkType>::New() and later not caring/writing about deletion.

There is a small list that I could fix immediately by inspecting a number of files, but there is a too long list in DiffusionImaging and ToFHardware, which I will only forward to the authors, who can also commit to this bug.

Event Timeline

maleike added a subscriber: maleike.

New remote branch pushed: bug-14455-vtksmartpointers

To find wrong usage, the folloging commandline is helpful

git grep 'vtkSmartPointer<[^>]\+>.*[a-zA-Z0-9_]\+.*=[^<]\+::New('

Committed fixes for ToFHardware to branch

Commited fixes for DiffusionImaging

[6e39d0]: Merge branch 'bug-14455-vtksmartpointers'

Merged commits:

2013-02-12 09:12:21 Peter Neher [93dd00]
fixes for DiffusionImaging


2013-02-07 16:51:49 Alexander Seitel [589b7f]
Corrected usage of vtkSmartPointer in classes of ToFHardware


2013-02-07 09:42:40 Daniel Maleike [5d0ecd]
Mark how vtkSmartPointer should be used, refer to bug


2013-02-07 09:40:02 Daniel Maleike [6f21eb]
Use vtkSmartPointer as intended


2013-02-07 09:39:47 Daniel Maleike [bef279]
Modules/Segmentation/Controllers/mitkSurfaceInterpolationController.cpp


2013-02-07 09:39:42 Daniel Maleike [26c01f]
Modules/Segmentation/Algorithms/mitkReduceContourSetFilter.cpp


2013-02-07 09:39:37 Daniel Maleike [7816d8]
Use vtkSmartPointer as intended


2013-02-07 09:39:18 Daniel Maleike [17a55d]
Use vtkSmartPointer as intended

Fixed in most places now. For the remaining two issues, I files T14482 and 14483, so this bug here can be finished.