Page MenuHomePhabricator

VTK Debug leaks when activating device in UltrasoundSupport
Closed, ResolvedPublic

Description

Activating a created device in the UltrasoundSupport plugin and closing the application afterwards, leads to VTK debug leaks.

For reproducing this issue MITK_VTK_DEBUG_LEAKS has to be activated in the CMake configuration.

Reproduced on current master (https://phabricator.mitk.org/rMITK647640c36bcc46b42991d6ed3ac87679e5fe28e5) on a Win 7 machine using a VS 32bit build.

Event Timeline

seitela triaged this task as Normal priority.Feb 6 2018, 6:12 PM
seitela created this task.

Debug leaks also occur in MITK v2016.11.

There's the issue, that removing a created USDevice doesn't lead to a destructor call of the respective instance. I'm expecting the device instance to be deleted. So I checked the reference count of the USDevice instance after removing it: After unregistering the device from the micro service, the reference count is 2.

I further investigated this and found a reference loop:
USAbstractControlInterface holds a reference to USDevice. The implementation of USVideoDevice (subclass of USDevice) holds a reference to USVideoDeviceCustomControls (subclass of USAbstractControlInterface).

After breaking the reference loop by using a weak pointer instead of a smart pointer, the USDevice as well as the USAbstractControlInterface instances are destructed. And also the VTK debug leaks are gone!