Closed kasemir closed 6 years ago
Python "widget" needs to be cleared after executing script:
After executing a script, Jython kept references to the last used 'widget' and 'pvs'. Now the 'widget' and 'pvs' are cleared after executing a script, no matter if script succeeded or failed.
Eclipse RCP keeps several references that I didn't anticipate. The items in a context menu linger around for quite some time until invoking a different context menu. Since the "Show Widget Info" or "Open Display in Editor" entries referred to a display, that kept the whole display in memory.
After a panel has been closed, Eclipse RCP keeps references to it, so again the data for all the widgets stayed in memory.
Now using 'weak' references and clearing all the widget detail when a panel is closed.
In a memory profiler, these changes show to result in a much better memory cleanup.
There seem to be a few memory leaks. Not necessarily when running even a large display for a long time, but they appear when opening and closing displays, especially when using scripts or running into errors.
Examples:
Open examples/plots_xy.bob, close it. SimpleDataItem, plot, .. is retained because PySystemState's "widget" variable still points to the plot.
Open a display with buggy script, script compilation fails, close the display. PVs of the script, listener, .. are retained.