You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Script language environments should be released #79
with a large dataset, memory usage showed persistent growth over time (clicking on status bar didn't free memory). Even after the script editor and image are closed.
Either the engine or the bindings need to be released
I am convinced this is fixed in #81 TextEditor has module and scriptInfo fields. These were never cleared after a normal run. Now they are unless the REPL mode is active. Closing it for now. Let's re-open it if the issue persists
The memory leak persists at least in the groovy script language. Using the above script and an 8GB image resulted in memory remaining claimed after closing the script editor.
The path to GC root goes to the script engine itself so the fix has to go through there.
@hinerm , This will nuke everything started by the script. E.g, this used to work, and it will now throw a MissingPropertyException:
importjavax.swing.*importjava.awt.event.*
counter =0
data = [1, 2, 3]
def frame =newJFrame("Bindings Release Test")
def buttonLabel =newJLabel(" Button: Click after the run has finished ")
def workerLabel =newJLabel(" Worker: waiting 3 s... ")
def button =newJButton("Read script variable")
// Test 1: a listener that outlives the run
button.addActionListener({ e->try {
counter++
buttonLabel.text ="Button: OK (counter="+ counter +")"
} catch (Throwable t) {
buttonLabel.text ="Button: FAILED ("+ t.class.simpleName +")"
}
} asActionListener)
// Test 2: A thread reading a variable after the script has returnedThread.start("bindings-worker") {
Thread.sleep(3000)
def msg
try {
msg ="Worker: OK (data="+ data +")"
} catch (Throwable t) {
msg ="Worker: FAILED ("+ t.class.simpleName +")"
}
SwingUtilities.invokeLater { workerLabel.text = msg }
}
def panel =newJPanel(newjava.awt.GridLayout(0, 1, 4, 4))
panel.add(buttonLabel)
panel.add(workerLabel)
panel.add(button)
frame.add(panel)
frame.pack()
frame.setVisible(true)
returnnull; //
Some of the own Fiji example scripts demo how to attach listeners to an image, so at least those will brake. But maybe, it is not a frequent use case?
Otherwise this would require some sort of preference checkbox in the Run menu that switches the clearing off entirely!? when on: everything works at the risk of memory problems. When off: Fixes #79 for everyone but more interactive scripts with callbacks or threads will break
I don't understand the example script in the issue report. Are you saying memory is not freed even after the shown image is closed again, due to persistent bindings? Can we make an MCVE that doesn't interact with SCIFIO's on-demand loading (like maybe it just allocates some big array)?
I reverted the binding release commit and reopened the issue for now.
@ctrueden correct. it's not an issue with SCIFIO; I included the heap dump to show that there is a clear path from the script bindings that prevents garbage collection of the image.
I can't reproduce the issue with large array allocation because
double[] data = new double[1_000_000_000]
tries to process data as an output and produces an exception. Changing it to:
double[] data = new double[1_000_000_000]
String g = "hello"
doesn't reproduce the issue so presumably it is an interaction with script inputs/outputs + the engine bindings specifically.
Activity
Fix #79
tferr commentedon Nov 16, 2026
I am convinced this is fixed in #81 TextEditor has module and scriptInfo fields. These were never cleared after a normal run. Now they are unless the REPL mode is active. Closing it for now. Let's re-open it if the issue persists
ScriptInstaller: Fix memory leak.
hinerm commentedon Nov 17, 2026
The memory leak persists at least in the groovy script language. Using the above script and an 8GB image resulted in memory remaining claimed after closing the script editor.
The path to GC root goes to the script engine itself so the fix has to go through there.
tferr commentedon Nov 17, 2026
@hinerm , This will nuke everything started by the script. E.g, this used to work, and it will now throw a
MissingPropertyException:Some of the own Fiji example scripts demo how to attach listeners to an image, so at least those will brake. But maybe, it is not a frequent use case?
Otherwise this would require some sort of preference checkbox in the Run menu that switches the clearing off entirely!? when on: everything works at the risk of memory problems. When off: Fixes #79 for everyone but more interactive scripts with callbacks or threads will break
ctrueden commentedon Nov 17, 2026
I don't understand the example script in the issue report. Are you saying memory is not freed even after the shown image is closed again, due to persistent bindings? Can we make an MCVE that doesn't interact with SCIFIO's on-demand loading (like maybe it just allocates some big array)?
hinerm commentedon Nov 17, 2026
I reverted the binding release commit and reopened the issue for now.
@ctrueden correct. it's not an issue with SCIFIO; I included the heap dump to show that there is a clear path from the script bindings that prevents garbage collection of the image.
I can't reproduce the issue with large array allocation because
tries to process
dataas an output and produces an exception. Changing it to:doesn't reproduce the issue so presumably it is an interaction with script inputs/outputs + the engine bindings specifically.