When enabling SCIFIO to be able to open KLB stacks (from Keller’s Lab single plane illumination microscope ), turns out that opening a 40 MB stack results in a 400 MB memory leak that doesn’t go away.
The issue is observed from a script, in either jython or clojure, which opens KLB images with IJ.openImage and then carefully calls .flush() on the ImagePlus and doesn’t keep any handle onto the image data.
When opening a single KLB file form “File - Open” and then closing the window with the mouse, the leak doesn’t seem to be there.
To bypass this issue, here is one fix, in jython:
from org.janelia.simview.klb import KLB klb = KLB.newInstance() paths = ... for path in paths: # Open as an ImgPlus, essentially an ImgLib2 Img<UnsignedShortType> imgplus = klb.readFull(path) # process the stack ...
In short, avoid using IJ.openImage, which uses the buggy SCIFIO framework when SCIFIO is enabled under “Edit - Options - ImageJ2”.
Hope this helps somebody.