NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 863 - Very slow opening images and Memory leak
Very slow opening images and Memory leak
Status: RESOLVED DUPLICATE of bug 819
Product: Fiji
Classification: Unclassified
Component: Plugins
unspecified
PC Windows
: P4 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2014-07-22 01:29 CDT by James Burchfield
Modified: 2014-07-23 01:09 CDT
3 users (show)

See Also:

Description James Burchfield 2014-07-22 01:29:49 CDT
Relative to imageJ and older Fiji incarnations, opening images has become very very slow.
Secondly, there appears to be something strange occuring with memory usage/allocation.
When  fiji is opened it appears to be using ~450MB memory (Windows task manager).
Open a 280MB image and memory usage jumps to 1.4GB.  Shut it down and memory usage remains at 1.4GB open another ~200MB image and usage jumps again to 2.2GB
Fiji itself thinks it is using 1269MB
This behaviour appears to continue with each image opened and closed.
The memory usage FIJI reports also continues to increase.  After opening and closing 4 images it reports 2.2GB of memory used.

Information about your version of Java:

  os.arch => amd64
  os.name => Windows 7
  os.version => 6.1
  java.version => 1.6.0_20
  java.vendor => Sun Microsystems Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_20-b02
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 16.3-b01
  java.vm.vendor => Sun Microsystems Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => sun.awt.Win32GraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => windows
  file.separator => \

The up-to-date check says: REMIND_LATER

Information relevant to JAVA_HOME related problems:

  JAVA_HOME is set to: C:\PROGRA~4\Fiji.app/java/win64/jdk1.6.0_20//jre
  imagej.dir => C:\PROGRA~4\Fiji.app

Information about the version of each plugin:

Activated update sites:
ImageJ: http://update.imagej.net/ (last check:20140712080647)
Fiji: http://pacific.mpi-cbg.de/update/ (last check:20140715100940)

Files not up-to-date:
  ff27659f (LOCAL_ONLY) 20110719184843 jars/Fiji.jar
  efd0b4a7 (OBSOLETE_UNINSTALLED) 20100614001000 jars/clibwrapper_jiio.jar
  d760adf7 (OBSOLETE_UNINSTALLED) 20101214182806 jars/commons-math.jar
  9654e601 (MODIFIED) 20140722104931 jars/imagej-updater-0.5.0.jar
  85af6645 (OBSOLETE_UNINSTALLED) 20110119134549 jars/imglib-algorithms.jar
  2727a642 (OBSOLETE_UNINSTALLED) 20110119134548 jars/imglib-ij.jar
  3913aead (OBSOLETE_UNINSTALLED) 20110119134549 jars/imglib-io.jar
  4053be28 (OBSOLETE_UNINSTALLED) 20110119134551 jars/imglib-scripting.jar
  785fd9ee (OBSOLETE_UNINSTALLED) 20110119134537 jars/imglib.jar
  b9040757 (OBSOLETE_UNINSTALLED) 20110119134352 jars/jruby.jar
  8e9a4bd8 (OBSOLETE_UNINSTALLED) 20110119134353 jars/junit-4.5.jar
  62509daf (OBSOLETE_UNINSTALLED) 20100614001000 jars/weka.jar
  290be785 (LOCAL_ONLY) 20101217124405 macros/Unwarp_redchannel image.txt
  ec9f9e6e 20100614001000 macros/grey-squares.ijm
  bc1d6c6e 20100614001000 macros/spirals.txt
  c4583991 (LOCAL_ONLY) 20140408102236 macros/testscript_temp_deleteME.ijm
  f7efa1b3 (LOCAL_ONLY) 20110314142721 misc/headless.jar
  8f675b7b (LOCAL_ONLY) 20140722105836 plugins/Align_RGB_planes.class
  5b9f64df (LOCAL_ONLY) 20140214104952 plugins/Convert_LIF_to_TIFF.class
  1a992dbc (OBSOLETE_UNINSTALLED) 20100614001000 plugins/Daltonize_.jar
  3e7c14cf (LOCAL_ONLY) 20140605204040 plugins/Filters/Anisotropic_Diffusion_2D.class
  a8c14ae3 (LOCAL_ONLY) 20140409165641 plugins/HDF5_.jar
  9cdfe434 20101214182818 plugins/Jython_Scripts.jar
  306c9af0 20101214182807 plugins/Macro_Examples.jar
  3589dfdf (LOCAL_ONLY) 20100408181022 plugins/MultiStackReg1_45.jar
  c32c3597 (LOCAL_ONLY) 20080521101406 plugins/MultiStackReg_.jar
  970c7851 (LOCAL_ONLY) 20130815113254 plugins/ROI/BG_Subtraction_from_ROI.class
  6f058434 (LOCAL_ONLY) 20140212100504 plugins/Radial Profiling/Radial_Profile_Angle_Ext.jar
  0ab9e3b0 (OBSOLETE_UNINSTALLED) 20100614001000 plugins/Record_Screen.jar
  424444d4 (LOCAL_ONLY) 20140428122029 plugins/Region_Growing_Segmentation.jar
  b8e50a7b (OBSOLETE_UNINSTALLED) 20110215125328 plugins/Script_Editor.jar
  4c3e4aee (NOT_INSTALLED) 20110119134407 plugins/Stack_Manipulation.jar
  2f7c1fb1 (LOCAL_ONLY) 20140310193004 plugins/Stack_Sorter.class
  e0122cde (LOCAL_ONLY) 20040909131042 plugins/Stacks - Reducing/Binner_.class
  ab872ecd (LOCAL_ONLY) 20040601145326 plugins/Stacks - Reducing/Delete_slices_after_here.class
  5e51feb8 (LOCAL_ONLY) 20040601145318 plugins/Stacks - Reducing/Delete_slices_before_here.class
  794c108d (LOCAL_ONLY) 20010207115620 plugins/Stacks - Reducing/Slice_Remover.class
  ff504eff (LOCAL_ONLY) 20060627090428 plugins/Stacks - Reducing/Stack_Splitter.class
  25874f3e (LOCAL_ONLY) 20030627131048 plugins/Stacks - Reducing/Substack_Maker.class
  b7a74d8a (LOCAL_ONLY) 20080526103622 plugins/Stacks - Reducing/Substack_Select.jar
  08564324 (LOCAL_ONLY) 20090921122950 plugins/Stacks - T-functions/Grouped_Stack_Projector.class
  3ae569df (LOCAL_ONLY) 20050202153014 plugins/Stacks - T-functions/Intensity_v_Time_Monitor.class
  03bba501 (LOCAL_ONLY) 20050202153404 plugins/Stacks - T-functions/Running_Stack_Projector.class
  1c657c8d (LOCAL_ONLY) 20140305190818 plugins/TIRF_Analysis.class
  5796a251 (LOCAL_ONLY) 20140303144901 plugins/X_Shifter.class
  8c0467d1 (LOCAL_ONLY) 20140120115836 plugins/adaptiveThreshold_win64.jar
  460fd731 (LOCAL_ONLY) 20140303144910 plugins/correctXshift_.jar
  30e408c8 (OBSOLETE_UNINSTALLED) 20110215125326 plugins/loci_tools.jar
  d3260180 (LOCAL_ONLY) 20100614001000 scripts/Record_Desktop.py
  0ea7f8fc (LOCAL_ONLY) 20100614001000 scripts/Record_Window.py
Comment 1 Mark Hiner 2014-07-22 08:21:19 CDT
Please read through the discussion of #819, especially Curtis Rueden's posts about using the windows task manager to monitor memory levels, and my own post to a GitHub issue describing the known memory leak.

As for the performance issue, it's certainly because the I/O module of ImageJ2 - SCIFIO - is still in beta and has not been optimized for performance yet. Some formats are definitely slower right now, especially TIFFs (in part due to broader TIFF support within SCIFIO compared to ImageJ 1.x).

You can read more about ImageJ2/SCIFIO here: http://imagej.net/ImageJ2 and if they are impeding your work, can be disabled until they become more performant.

*** This bug has been marked as a duplicate of bug 819 ***
Comment 2 Johannes Schindelin 2014-07-22 08:47:45 CDT
Whoops, mid-air collision! However, I still would like to provide my input:

First of all, thank you for the bug report. As you well know, the ImageJ/Fiji projects only work because of the collaborative spirit of the ImageJ community.

Now some background: in ImageJ 1.x, there is not really any good extension mechanism for file input/output. Sure, there are some plugins implementing readers and writers, although they frequently miss metadata due to the utterly free nature of plugins that provide little guiding for implementers.

The first attempt at an extension mechanism was made by Greg Jefferis who implemented the method where you can provide a plugin class called `HandleExtraFileTypes` that ImageJ 1.x looks for if it does not know about a certain file type, letting that (meta) plugin handle the file loading.

However, the `HandleExtraFileTypes` approach has three obvious shortcomings:

- just like with Highlander, there can be only one. Two independent projects cannot extend the file input/output independently: if users install two .jar files containing a `HandleExtraFileTypes` class each, only one will win. The other will be ignored. We had a lot of fun with that in Fiji.

- since `HandleExtraFileTypes` is a meta plugin, handing off based on some indicators inferred from the file name and/or the first 1024 bytes, it inherits all the problems about lacking metadata (or even worse, metadata provided in incompatible ways by different reader plugins).

- some file types cannot be handled by `HandleExtraFileTypes` because ImageJ 1.x thinks it knows them. The most prominent example is certainly the OME-TIFF: it has the file extension .ome.tiff, but ImageJ 1.x misinterprets the .tiff extension to mean that its internal `TiffDecoder` class -- which does not know the first thing about OME-TIFFs of course, missing all the metadata. Of course, the OME-TIFF issue could be worked around in ImageJ 1.x by special-casing .ome.tiff, but that would just paper over the fundamental issue that ImageJ 1.x simply cannot be extended in a way overriding its internal readers and writers.

The last point also illuminates another crucial point about the ImageJ 1.x file input/output handling: the *core* readers/writers of ImageJ 1.x do not use the same mechanism as third-party readers/writers have to use, thereby making things inconsistent.

To address this issue, the architecture of ImageJ2 demanded a switch to consistent, powerful file input/output plugins, using the very same mechanism for *all* file input/output, including for the default readers/writers. The default readers/writers can also be overridden by implementing plugins with a higher priority.

Now, the ImageJ2 project has a long term vision -- which makes things a little more complicated in the short run, but ultimately infinitely more robust even in the intermediate future. For example, the plugin framework has been made modular -- recognizing the fact that it is not specific to image processing at all -- and put into its own component: scijava-common.

Likewise, the file input/output does not need to be specific to ImageJ now, does it? That is why it lives in its own component, SCIFIO. The benefit should be quite obvious when you look how widely usable SCIFIO is even *outside* ImageJ: ITK, for example, a very powerful (and complex) C++ library, uses SCIFIO to support hundreds of file types.

Back to your concrete report, I see that you actually have *two* issues, one of which needs feedback.

1) there is a memory leak. Actually, I do not really know about that because you use the task manager which is notoriously unreliable to assess memory usage by Java virtual machines (due to the specifics of JVM memory management). We will have to invest some time here to figure out whether it is a *real* or an *unreal* issue: if the JVM deallocates memory only reluctantly, for performance reasons, you would see the symptoms you described, but it would actually *not* be a problem.

2) the slowness of SCIFIO. Since SCIFIO -- like `HandleExtraFileTypes` -- relies on format-specific plugins, it is not enough to report that it is slow. You will need to provide us with an example image (the smaller the example image is without sacrificing the slowness symptom, the better): just upload it with Help>Upload Sample Image and leave a note in this bug report.

As to 2) a word of caution: we often see that users compare in particular the performance of SCIFIO's Tiff reader with ImageJ 1.x' TiffDecoder, not knowing that the latter takes a couple of shortcuts that actually violate the Tiff standard. In other words, we try to make SCIFIO's readers *robust* and *correct* at the moment and hope to soon enter the phase where we also make them *fast*.
Comment 3 James Burchfield 2014-07-23 01:09:22 CDT
Thanks Mark and Johannes.
Much appreciated.

With regards to the memory leak. It (or something similar) is also present in ImageJ 1.x albeit not as bad (memory usage doesn't build up as fast) 

After manually opening, process (RGB align) and closing several (~10) 200MB images, the ImageJ memory manager is using 4324MB of 20000MB.

After 25 or so repetitions the performance of the whole system starts to lag and a restart seems the only way to restore functionality.

Cheers
James