bioformats
bioformats copied to clipboard
showinf `OutOfMemoryError` with large JPG file
We stumble had an error on a large jpeg image (6 624 x 40 653 px, 214 MB) when calling showinf
(through omero transfer prepare
)
Here is the trace:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.desktop/java.awt.image.DataBufferByte.<init>(DataBufferByte.java:93)
at java.desktop/java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:433)
at java.desktop/java.awt.image.Raster.createWritableRaster(Raster.java:1121)
at java.desktop/javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1066)
at java.desktop/javax.imageio.ImageReader.getDestination(ImageReader.java:2877)
at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1200)
at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1162)
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1466)
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1363)
at loci.formats.in.ImageIOReader.initImage(ImageIOReader.java:148)
at loci.formats.in.ImageIOReader.initFile(ImageIOReader.java:121)
at loci.formats.in.JPEGReader$DefaultJPEGReader.initFile(JPEGReader.java:203)
at loci.formats.FormatReader.setId(FormatReader.java:1421)
at loci.formats.DelegateReader.setId(DelegateReader.java:291)
at loci.formats.in.JPEGReader.setId(JPEGReader.java:87)
at loci.formats.ImageReader.setId(ImageReader.java:849)
at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
at loci.formats.tools.ImageInfo.testRead(ImageInfo.java:1035)
at loci.formats.tools.ImageInfo.main(ImageInfo.java:1121)
The file can be downloaded (till April 26th 2024, ping me here if you need it later) at that link:
https://filesender.renater.fr/?s=download&token=5052c708-6aeb-44b4-bae5-e570db81d985
showinf -version
Version: 6.7.0
Build date: 23 August 2021
VCS revision: aef40b42965e2fea2dfd7b431cf503c8a1980903
I was able to recreate the problem with showinf.bat from the bftools programs.
I saw the problem go away when I increased the Java Max Heap size to 15g by setting a bftools environment variable BF_MAX_MEM:
cmdprompt> set BF_MAX_MEM=15g
The following are the commands to first show the problem and then display the image after setting BF_MAX_MEM to 15g
cmdprompt> showinf ......\WORKSPACE\standalone\IHC45-10xLyz.jpg
Checking file format [JPEG]
Initializing reader
JPEGReader initializing ......\WORKSPACE\standalone\IHC45-10xLyz.jpg
Populating metadata
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferByte.
cmdprompt> set BF_MAX_MEM=15g
cmdprompt> showinf ......\WORKSPACE\standalone\IHC45-10xLyz.jpg Checking file format [JPEG] Initializing reader JPEGReader initializing ......\WORKSPACE\standalone\IHC45-10xLyz.jpg Populating metadata Parsing JPEG EXIF data Initialization took 6.535s
Reading core metadata filename = ......\WORKSPACE\standalone\IHC45-10xLyz.jpg Series count = 1 Series #0 : Image count = 1 RGB = true (3) Interleaved = false Indexed = false (true color) Width = 6624 Height = 40653 SizeZ = 1 SizeT = 1 SizeC = 3 (effectively 1) Tile size = 6624 x 40653 Thumbnail size = 20 x 128 Endianness = motorola (big) Dimension order = XYCZT (certain) Pixel type = uint8 Valid bits per pixel = 8 Metadata complete = true Thumbnail series = false ----- Plane #0 <=> Z 0, C 0, T 0
Reading pixel data (0-0) Read 1/1 planes (100%) [done] 18.307s elapsed (18307.0ms per plane)
Launching image viewer
Reading global metadata Color Space: sRGB Date/Time Digitized: 23-Oct-23 15:56:54 Lens Model: PLAN APO ╬╗D 10x OFN25 DIC N1
Reading metadata
The image then got displayed.
I'm very new to bioformats,omero,showinf, etc so I'm not sure of your environment.
So maybe try setting the environment variable to 15g and then try your commands.
set BF_MAX_MEM=15g
I do see BF_MAX_MEM mentioned in this doc:
https://bio-formats.readthedocs.io/_/downloads/en/v6.13.0/pdf/
Also, doing a Google search on BF_MAX_MEM shows several discussions about using BF_MAX_MEM.
Hi, thanks a lot @scuniff, I'm trying this today, and closing this following up