rokkito / android-casual

Automatically exported from code.google.com/p/android-casual
0 stars 0 forks source link

Requested array size exceeds VM limit #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Occurred on linux box, Oracle JVM 8 with -Xmx32G.

Stack trace:
Exception in thread "Thread-56" java.lang.OutOfMemoryError: Requested array 
size exceeds VM limit
        at CASUAL.communicationstools.heimdall.odin.OdinFile.extractOdinContents(OdinFile.java:145)
        at CASUAL.communicationstools.heimdall.odin.Odin.getHeimdallFileParametersFromOdinFile(Odin.java:50)
        at com.casual_dev.jodin.JOdinController.getHeimdallCommandFromOdinPackageList(JOdinController.java:621)
        at com.casual_dev.jodin.JOdinController.access$3300(JOdinController.java:54)
        at com.casual_dev.jodin.JOdinController$13.run(JOdinController.java:572)
        at java.lang.Thread.run(Thread.java:745)

Issues:
Available size to read from stream may exceed 2^31-1 if file is cached.
Available bytes == 0 does not indicate end of stream. Available bytes < 0 does.

Fix:
        byte[] buffer = new byte[1024 * 1024];
        int len;
        while (len = tarStream.read(buffer)) {
            if (len < 0) {
                break;
            }
            outputFileStream.write(buffer, 0, len);
        }

Original issue reported on code.google.com by Grant.Ov...@gmail.com on 23 Oct 2014 at 6:21

GoogleCodeExporter commented 8 years ago
Correction on fix:

        byte[] buffer = new byte[1024 * 1024];
        int len;
        while ((len = tarStream.read(buffer)) >= 0) {
            outputFileStream.write(buffer, 0, len);
        }

Original comment by Grant.Ov...@gmail.com on 23 Oct 2014 at 6:27