Ticket #4389 (closed: fixed)

Opened 9 years ago

Last modified 5 years ago

Python handle still valid after DeleteWorkspace in MantidPlot

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Release 2.0
Component: Mantid Keywords:
Cc: Blocked By:
Blocking: Tester: Jose Borreguero

Description

On the command line the calling DeleteWorkspace and then trying to reuse a workspace handle results in an exception being raised but the same does not happen in MantidPlot. The script below demonstrates the problem

from mantid import FrameworkManager
from mantid.simpleapi import LoadRaw, DeleteWorkspace

filename = '/home/dmn58364/mantidproject/test-scripts/inelastic/direct/Mantid_vs_Libisis_MAPS/RAW_files/MAP17265.raw'

raw_sample = LoadRaw(Filename=filename, LoadLogFiles="0")
print raw_sample.getNumberHistograms()
DeleteWorkspace(raw_sample)
print raw_sample.getNumberHistograms()

It should raise this error

Traceback (most recent call last):
  File "test-leak.py", line 9, in <module>
    print raw_sample.getNumberHistograms()
RuntimeError: Variable invalidated, data has been deleted.

Change History

comment:1 Changed 9 years ago by Martyn Gigg

Refs #4389. Add a PostDeleteNotification to the DataService.

Most observers that watch for workspace deletion do not need a copy of the shared pointer. The PostDeleteNotification only has the name of what was deleted meaning the object should only be kept alive by a notification if absolutely necessary. The PreDeleteNotification does what the original DeleteNotification did.

Changeset: bdf3b719f578f7478c64d9e411dd4aa3dfac720b

comment:2 Changed 9 years ago by Martyn Gigg

Refs #4389. Try to ensure memory is returned promptly.

Changeset: a4eef1d55c5a1b0ef1450d3f4947c089a9d5a6d8

comment:3 Changed 9 years ago by Martyn Gigg

  • Status changed from new to accepted

comment:4 Changed 9 years ago by Martyn Gigg

  • Status changed from accepted to verify
  • Resolution set to fixed

comment:5 Changed 9 years ago by Martyn Gigg

Refs #4389. Remove a variable that causes a spurios memcheck error

Changeset: eebb1b9f4d23b619e6ed5e981f4360aeeb36b269

comment:6 Changed 9 years ago by Jose Borreguero

  • Status changed from verify to verifying
  • Tester set to Jose Borreguero

comment:7 Changed 9 years ago by Jose Borreguero

  • Status changed from verifying to closed

comment:8 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 5236

Note: See TracTickets for help on using tickets.