Skip to content

Android OutOfMemoryError occurs when readTiff for 400MB tif file #31

@songhu42

Description

@songhu42

Please fill out as much known and relevant information as possible.

Version Information:

  • TIFF Java Version: 2.0.2
  • TIFF Java Source: Central Repository
  • IDE Name & Version: Android Studio 3.2.1
  • Maven Version: (mvn -version) : gradle:3.2.1
  • Java Version: (java -version) : Android-26
  • Platform & OS: Android
  • Other Relevant Libraries:

Expected Results:

  • What did you expect to happen?
    Open the big tif file : TiffReader.readTiff(tiffFile)

Observed Results:

  • What happened instead?
    AndroidRuntime: FATAL EXCEPTION: Thread-19
    java.lang.OutOfMemoryError: Failed to allocate a 536870928 byte allocation with 25165824 free bytes and 234MB until OOM, target footprint 316450016, growth limit 536870912

  • How often does this occur? Always

Output:

  • Any logs, errors, or output messages?
    java.lang.OutOfMemoryError: Failed to allocate a 536870928 byte allocation with 25165824 free bytes and 234MB until OOM, target footprint 316450016, growth limit 536870912
    at java.util.Arrays.copyOf(Arrays.java:3161)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
    at mil.nga.tiff.io.IOUtils.copyStream(IOUtils.java:104)
    at mil.nga.tiff.io.IOUtils.streamBytes(IOUtils.java:83)
    at mil.nga.tiff.io.IOUtils.fileBytes(IOUtils.java:67)
    at mil.nga.tiff.TiffReader.readTiff(TiffReader.java:51)
    at mil.nga.tiff.TiffReader.readTiff(TiffReader.java:35)
    at com.mvsoftech.mvgis.forestServices.DemFinder$2.run(DemFinder.java:49)
    at java.lang.Thread.run(Thread.java:919)

Steps to Reproduce:

  1. just run app in mobile

Relevant Code:

// Code to reproduce the problem?
TIFFImage tiffImage = TiffReader.readTiff(tiffFile);

Test Files:

  • Links to any files needed for testing?

Additional Information:

  • Any additional configuration, data, or information that might help with the issue?
  • Thank you If you can fix it

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions