mantidproject / mantidimaging

Graphical toolkit for neutron imaging.
https://mantidproject.github.io/mantidimaging
GNU General Public License v3.0
13 stars 6 forks source link

TaskWorkerThread ImageStack leak #1378

Closed samtygier-stfc closed 2 years ago

samtygier-stfc commented 2 years ago

Summary

In the gui system tests an ImageStack is being leaked probably due to a reference in TaskWorkerThread.

The issue is probably, why is the TaskWorkerThread still alive.

Steps To Reproduce

In mantidimaging/gui/test/gui_system_base.py change the leak tracker call to leak_tracker.pretty_print(debug_init=False, debug_owners=True, trace_depth=5)

run xvfb-run --auto-servernum pytest -vs -rs --run-system-tests -k test_minimise

Current Behaviour

Items still alive: 44
 Object: <class 'numpy.ndarray'> pyid=139681282501104  ndarray: (1, 512, 512) float32
  item_info.msg='ImageStack untitled'
 Ownership:
     <class 'mantidimaging.gui.dialogs.async_task.model.AsyncTaskDialogModel'> pyid=139681282527088 
     <class 'dict'> pyid=139681283123008  keys={'task'}
     <class 'mantidimaging.gui.dialogs.async_task.task.TaskWorkerThread'> pyid=139681282555968 
     <class 'dict'> pyid=139681283122176  keys={'result'}
     <class 'mantidimaging.core.data.imagestack.ImageStack'> pyid=139681282507776  obj.name=untitled obj.id=38915926-f953-41a5-8bdf-30f08c5a12bc
     <class 'dict'> pyid=139681283123328  keys={'_data'}
     <class 'numpy.ndarray'> pyid=139681282501104  ndarray: (1, 512, 512) float32

...

Context

Current main

samtygier-stfc commented 2 years ago

The ImageStack is in the result field of TaskWorkerThread, so this is not from the ReconstructWindowModel.auto_find_minimisation_sqsum async tasks which return a list of floats.

Seems to be from the many calls wtih ReconstructWindowModel.run_preview_recon that are made. If I output images.id in _on_preview_reconstruct_slice_done then they match the leaked imagestacks.