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

[feature] Optimize memory usage #1410

Closed
b0123456789 opened this issue Mar 17, 2022 · 12 comments
Closed

[feature] Optimize memory usage #1410

b0123456789 opened this issue Mar 17, 2022 · 12 comments

Comments

@b0123456789
Copy link

b0123456789 commented Mar 17, 2022

I alway notice that "memory not enough, XX classes not index, please increase heap size and restart" when input a big file and search some thing.

@b0123456789
Copy link
Author

b0123456789 commented Mar 17, 2022

Is it possible to use file cache replace with memory to decrease memory usage ?

@jpstotz
Copy link
Collaborator

jpstotz commented Mar 17, 2022

Have you read our Wiki section about memory problems? https://github.com/skylot/jadx/wiki/Troubleshooting-Q&A#out-of-memory-problems

Additionally I strongly recommend you not to use Java 8. Use Java 11 or 17 instead. Since Java 9 strings usually have a reduced memory footprint (up to 50%). All the code you see in Jadx are strings in memory so using Java 11/17 can reduce memory usage a lot.

@skylot As far as I know Oracle Java 8 is EOL February 2022. Some OpenJDK Java 8 versions are supported a little longer but Java 8 in general seems to come to an end. What do you think about how long we should continue Jadx support Java 8?

@b0123456789
Copy link
Author

I installed java11 ,my memoy only has 8G.
even if i increase memory to 4G, it still has the problem, if i increase more , my pc will crash.

@b0123456789
Copy link
Author

I use android studio never has the problem, even if i load a big project.

@jpstotz
Copy link
Collaborator

jpstotz commented Mar 17, 2022

Jadx is designed to decompile everything in RAM as this is way faster and easier to implement.
A file-based database may be implemented in future.

The only way to decrease memory usage at the moment is to exclude packages you are not interested in or to only selectively decompile classes.

@b0123456789
Copy link
Author

Thx

@skylot
Copy link
Owner

skylot commented Mar 17, 2022

@b0123456789

Is it possible to use file cache replace with memory to decrease memory usage ?

Sure, this can be done, this will also help to continue work on project after jadx reopen (related to #784).
I already implemented POC some time ago, but it shows a lot of issues in performance (especially in search) and in overall jadx internal architecture, so this needs a lot of preparations and changes.

@jpstotz

As far as I know Oracle Java 8 is EOL

Yeah, I also want to move to newer java releases. I already change required java version to 11 in download section and encourage people to use the latest version in release notes. But still some people use Java 8 for some reason 😐 (issues like #1373 and #1280).
Also, I need to mention that runtime java version and compilation target version are different issues. For runtime, it is always better to use the latest Java version, but compilation target version can be still be old and this not affect performance much. Using old java API is not a big deal, so using Java 8 for jadx library is fine for now. And as I see, only small amount of libraries on maven central moved to java 11, so I also will not rush things on this part.

@skylot
Copy link
Owner

skylot commented Mar 17, 2022

@b0123456789 forget to say: If possible, please share your apk, so I can profile it, and maybe I will find some issues which causes increased memory usage.

@b0123456789
Copy link
Author

classes.dex.all.zip

@b0123456789
Copy link
Author

b0123456789 commented Mar 17, 2022

Sorry for later

The app can't upload becouse of it is to big. if you need this, i'll upload tomorrow。
the app has a shell to hide dex files.
the classes.dex.all.zip is dump from the app by frida_dump.
i use this to analyse with jadx.

@skylot
Copy link
Owner

skylot commented Mar 17, 2022

@b0123456789 thanks for the sample!
I commit several tweaks to improve memory usage, also processing threads count will be reduced on low memory automatically.
These changes allow me to successfully decompile your sample with 4 GB on Java 17.

@b0123456789
Copy link
Author

Thx,it work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants