OutOfMemoryError while reading tif
See original GitHub issueHi, we were getting following OOME while reading one of our tif images:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readValue(TIFFReader.java:461)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readValueAt(TIFFReader.java:372)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readEntry(TIFFReader.java:345)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readIFD(TIFFReader.java:178)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readSubIFDs(TIFFReader.java:229)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readIFD(TIFFReader.java:194)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.readLinkedIFDs(TIFFReader.java:151)
at com.twelvemonkeys.imageio.metadata.tiff.TIFFReader.read(TIFFReader.java:132)
at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:187)
at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.readIFD(TIFFImageReader.java:380)
at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:916)
at javax.imageio.ImageIO.read(ImageIO.java:1462)
I suppose that the image metadata are corrupted as I was able to get rid of this error by altering the image (e.q. by opening the image and saving again in graphical editor or manually just with the text editor). Would be nice if you could improve the twelvemonkeys implementation and skip loading of metadata to prevent OOME in such case as other tools can read the image without crash.
Code to read image:
BufferedImage image = ImageIO.read(new URL(wrong));
Tested with imageio 3.7.0 and 3.8.1.
The problematic image is attached in .zip as tif format is not supported as attachment. P07.61-3863-76_M178-Farbe.zip
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Out of memory exception when loading tif file in a picture box
i solve this problem by changing Pixel format of my loaded image using this code : Bitmap orig = new Bitmap(filePath); Bitmap clone...
Read more >Plotting tiff file giving Memory Error - GIS Stack Exchange
A MemoryError like this usually means that something ran out of memory (i.e. it's too big for your system to process as is)....
Read more >Concatenating tif files into one causing out of memory issues
We are getting out of memory error while concatenation get tif files using aspose.imaging.jar ... Details: There is no more data to read....
Read more >OutOfMemory exceptions importing ome.tiff files over 9 or 10GB
I have several ome.tiff files that I have exported from our software ... Files around 9GB are throwing Java heap space out of...
Read more >High resolution TIFF images causing Out Of Memory during ...
In the case of the 16K image, the conversion processes consume all available heap memory and turning to Out Of Memory error. In...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FIY: I added a small fix that will detect this situation and handle it gracefully, even if reading from URL. Will be included in next release.
Hi Harald, thanks a lot. You’re right. The image can be read as a file. The exception above was my fault - I used original URL source with “file:///” protocol prefix at the beginning of the path. Now it works fine.