Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showinf OutOfMemoryError with large JPG file #4175

Open
glyg opened this issue Mar 28, 2024 · 3 comments
Open

showinf OutOfMemoryError with large JPG file #4175

glyg opened this issue Mar 28, 2024 · 3 comments

Comments

@glyg
Copy link

glyg commented Mar 28, 2024

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
@scuniff
Copy link

scuniff commented Apr 2, 2024

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.(Unknown Source)
at java.awt.image.ComponentSampleModel.createDataBuffer(Unknown Source)
at java.awt.image.Raster.createWritableRaster(Unknown Source)
at javax.imageio.ImageTypeSpecifier.createBufferedImage(Unknown Source)
at javax.imageio.ImageReader.getDestination(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
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:220)
at loci.formats.FormatReader.setId(FormatReader.java:1480)
at loci.formats.DelegateReader.setId(DelegateReader.java:291)
at loci.formats.in.JPEGReader.setId(JPEGReader.java:100)
at loci.formats.ImageReader.setId(ImageReader.java:865)
at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:692)
at loci.formats.tools.ImageInfo.testRead(ImageInfo.java:1043)
at loci.formats.tools.ImageInfo.main(ImageInfo.java:1129)
c:\steve\java\BIOFORMATS\CmdLineTools\bftools\bftools>
c:\steve\java\BIOFORMATS\CmdLineTools\bftools\bftools>
c:\steve\java\BIOFORMATS\CmdLineTools\bftools\bftools>

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

@scuniff
Copy link

scuniff commented Apr 2, 2024

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.

@glyg
Copy link
Author

glyg commented Apr 2, 2024

Hi, thanks a lot @scuniff, I'm trying this today, and closing this following up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants