Konloch / bytecode-viewer

A Java 8+ Jar & Android APK Reverse Engineering Suite (Decompiler, Editor, Debugger & More)
https://bytecodeviewer.com
GNU General Public License v3.0
14.71k stars 1.15k forks source link

RAM usage skyrockets when opening and closing big JARs #482

Closed threefusii closed 10 months ago

threefusii commented 10 months ago

Description

May be related to #251. Opening a lot of files and then closing (aka deleting) them won't release them from the RAM. Also the "Reload Resources" button will load "deleted" jars from the app.

Steps to reproduce

  1. Download some big heavy (possibly shaded) JAR, like Reposilite JAR.
  2. Cap the bytecode viewer at 2GB of RAM with java -Xmx2G -jar filename.jar.
  3. Open the shaded jar with the viewer. (don't decompile any classes, just open)
  4. On my system it loads to approx 1.5GB RAM and works just fine.
  5. Close the JAR. (Right click and "Delete")
  6. Repeat the steps 3-5. Notice that the RAM usage will grow. Repeat again and again and again. After a few attempts the VM will crash with OutOfMemoryError or the GC will eat your CPU usage. (or both)

Info

OS: Win10 x64 Java: Zulu 21.0.1+12 Bytecode Viewer versions tested: 2.12 (from releases) and a1d9c15 (from actions)

Konloch commented 10 months ago

One work around may be to change the theme, I've encountered this issue on my own machine and my solution is to change the theme over to the System Theme. Then importing jars with lots of assets (files, classes, etc) seems to be a lot more manageable.

threefusii commented 10 months ago

I'm not sure, but there is a clear memory leak if the GC can't free the memory. A manual System.gc() on closing/opening or as a button will be good anyway, even if it won't fix the problem.

Also i tested with the "System Theme" and the issue still persists.

Bl3nd commented 10 months ago

Tested the current version, I ran it with -Xmx1024m to see if I can force an OutOfMemory. It never did and it reset the memory usage. Without setting a -Xmx, it keeps building usage until a certain point(in my case it was using about 23% of my 32gb and never grew after that but stayed at the 20-ish %). If you could test it also to see if you get the same results, that'd be great.

threefusii commented 10 months ago

Yep, the issue seems to be fixed in aea66fe