bytecode-viewer icon indicating copy to clipboard operation
bytecode-viewer copied to clipboard

Exception in thread "Import Resource" java.lang.OutOfMemoryError: Java heap space

Open Aquilax007 opened this issue 2 years ago • 3 comments

I wanted to take a look to the source code of State of Survival, alas the decompilation failed.

Opening...D:\Apps\state-of-survival-1-14-46.apk
I: Using Apktool 2.6.0 on bVKcmpSfEapXHfazxdtrWHYfwnrehQBa.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\aquilax007\.Bytecode-Viewer\bcv_temp\beMallVisKSP\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
Exception in thread "Import Resource" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at java.io.ByteArrayOutputStream.grow(Unknown Source)
        at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
        at java.io.ByteArrayOutputStream.write(Unknown Source)
        at the.bytecode.club.bytecodeviewer.util.MiscUtils.getBytes(MiscUtils.java:343)
        at the.bytecode.club.bytecodeviewer.util.JarUtils.loadResources(JarUtils.java:216)
        at the.bytecode.club.bytecodeviewer.resources.importing.impl.APKResourceImporter.open(APKResourceImporter.java:56)
        at the.bytecode.club.bytecodeviewer.resources.importing.ImportResource.importKnownFile(ImportResource.java:87)
        at the.bytecode.club.bytecodeviewer.resources.importing.ImportResource.run(ImportResource.java:59)
        at java.lang.Thread.run(Unknown Source)

Aquilax007 avatar Mar 23 '22 13:03 Aquilax007

Thank you for the report!

You may be able to resolve the issue if you run BCV with the argument XMX[heapsize] - java -Xmx3G -jar BCV.jar this would start BCV with 3 GB, you could keep increasing it relative to your systems available memory if the 3 GB wasn't enough.

One long term solution may be adjusting the load mechanism to stream the APK rather than trying to load all of it into memory, but I'm not sure if the libraries we use would support that.

Konloch avatar Mar 26 '22 13:03 Konloch

@Konloch This error actually looks like it is only BCV-related since APKTool is able to load it correctly, but BCV then tries to load everything itself and then it fails. This specific error could be avoided by adjusting only BCV, I think. But yes, if we want to get rid of most of such errors, we need to ask the corresponding maintainers for support, I guess.

ThexXTURBOXx avatar Mar 27 '22 17:03 ThexXTURBOXx

I got this error after accidentally installing and using Java 32-bit. Using 64-bit allows for a larger heap and fixes this error

lukew3 avatar Jan 17 '24 23:01 lukew3