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

How to increase Java heap space? #9

Closed
fuomag9 opened this issue Jul 29, 2024 · 1 comment
Closed

How to increase Java heap space? #9

fuomag9 opened this issue Jul 29, 2024 · 1 comment

Comments

@fuomag9
Copy link

fuomag9 commented Jul 29, 2024

Hi, is there any way to pass java arguments for increasing java heap space? Currently mine crashes like this:

Creating output directory: /base-decompiled0000%) |
Output directory created: /base-decompiled
Running jadx on base.apk
INFO  - loading ...
ERROR - Process error:
java.lang.OutOfMemoryError: Java heap space
	at java.base/jdk.internal.misc.Unsafe.allocateUninitializedArray(Unsafe.java:1375)
	at java.base/java.lang.StringConcatHelper.newArray(StringConcatHelper.java:497)
	at java.base/java.lang.StringConcatHelper.newArrayWithSuffix(StringConcatHelper.java:475)
	at java.base/java.lang.invoke.DirectMethodHandle$Holder.invokeStatic(DirectMethodHandle$Holder)
	at java.base/java.lang.invoke.LambdaForm$MH/0x000000100100d000.invoke(LambdaForm$MH)
	at java.base/java.lang.invoke.LambdaForm$MH/0x000000100100e000.invoke(LambdaForm$MH)
	at java.base/java.lang.invoke.Invokers$Holder.linkToTargetMethod(Invokers$Holder)
	at jadx.core.utils.Utils.makeQualifiedObjectName(Utils.java:55)
	at jadx.core.codegen.TypeGen.signature(TypeGen.java:25)
	at jadx.core.dex.info.MethodInfo.makeShortId(MethodInfo.java:90)
	at jadx.core.dex.info.MethodInfo.<init>(MethodInfo.java:33)
	at jadx.core.dex.info.MethodInfo.fromRef(MethodInfo.java:52)
	at jadx.core.dex.nodes.MethodNode.<init>(MethodNode.java:92)
	at jadx.core.dex.nodes.MethodNode.build(MethodNode.java:86)
	at jadx.core.dex.nodes.ClassNode.lambda$load$1(ClassNode.java:126)
	at jadx.core.dex.nodes.ClassNode$$Lambda$217/0x00000010011c8000.apply(Unknown Source)
	at jadx.api.plugins.input.data.impl.ListConsumer.accept(ListConsumer.java:25)
	at jadx.plugins.input.dex.sections.DexClassData.readMethods(DexClassData.java:170)
	at jadx.plugins.input.dex.sections.DexClassData.visitMethods(DexClassData.java:145)
	at jadx.plugins.input.dex.sections.DexClassData.visitFieldsAndMethods(DexClassData.java:112)
	at jadx.core.dex.nodes.ClassNode.load(ClassNode.java:127)
	at jadx.core.dex.nodes.ClassNode.<init>(ClassNode.java:115)
	at jadx.core.dex.nodes.RootNode.lambda$loadClasses$0(RootNode.java:128)
	at jadx.core.dex.nodes.RootNode$$Lambda$212/0x00000010011be700.accept(Unknown Source)
	at jadx.plugins.input.dex.DexReader.visitClasses(DexReader.java:35)
	at jadx.plugins.input.dex.DexLoadResult.visitClasses(DexLoadResult.java:26)
	at jadx.core.dex.nodes.RootNode.loadClasses(RootNode.java:126)
	at jadx.api.JadxDecompiler.load(JadxDecompiler.java:125)
	at jadx.cli.JadxCLI.processAndSave(JadxCLI.java:51)
	at jadx.cli.JadxCLI.execute(JadxCLI.java:38)
	at jadx.cli.JadxCLI.main(JadxCLI.java:22)
Successfully decompiled base.apk with jadx

Indexing decompiled files in /base-decompiled/jadx...
Found 0 decompiled files for base.apk
Status: COMPLETE | Decompiled: 1/1 (100.000000%) |

Decompiling COMPLETE. Decompiled 1 files with 1 errors. Elapsed time: 0:00:32.582309

Status: COMPLETE | Decompiled: 1/1 (100.000000%) |
Found 0 new secrets (0 unique).
Decompiled 1 files with 1 errors in 0:00:32.582309.
Scanned 0 files and found 0 secrets in None.
Total Elapsed time: 0:00:32.592548

Output written to secrets_output.json

APKscan done. No secrets found.
@fuomag9 fuomag9 closed this as completed Jul 29, 2024
@LucasFaudman
Copy link
Owner

Hi @fuomag9,

Thanks for your feedback! I saw your already closed this issue but wanted to provide a solution anyway for anyone else reading this.

Heap size is actually set by your environment's _JAVA_OPTIONS, not by APKscan, JADX, or any other dependancies.

To increase the heap space for a Java application and avoid java.lang.OutOfMemoryError: Java heap space, you can modify the _JAVA_OPTIONS environment variable to specify the desired heap size.

# Desired heap size ie: 1g = 1GB, 2g = 2GB, 4g = 4GB, 100m = 100MB, etc
heap_size="4g"
heap_size_arg="-Xmx$heap_size"

# Check if _JAVA_OPTIONS is set
if [ -z "$_JAVA_OPTIONS" ]; then
    export _JAVA_OPTIONS="$heap_size_arg"
else
    # Check if _JAVA_OPTIONS contains -Xmx
    if echo "$_JAVA_OPTIONS" | grep -q '\-Xmx'; then
        # Replace existing -Xmx value
        export _JAVA_OPTIONS=$(echo "$_JAVA_OPTIONS" | sed -E "s/\-Xmx[0-9]+[kKmMgG]/$heap_size_arg/")
    else
        # Add -Xmx value
        export _JAVA_OPTIONS="$_JAVA_OPTIONS $heap_size_arg"
    fi
fi

# Verify the setting
echo "Current _JAVA_OPTIONS: $_JAVA_OPTIONS"

@LucasFaudman LucasFaudman pinned this issue Aug 2, 2024
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