GoldenGnu / jeveassets

jEveAssets is an out-of-game asset manager for Eve-Online, written in Java
http://eve.nikr.net/jeveasset
GNU General Public License v2.0
155 stars 39 forks source link

Future Optimization Look #384

Open Mr00Anderson opened 1 year ago

Mr00Anderson commented 1 year ago

Once my Jeveassets has gotten robust I had to close most tabs, and still use 12GB ram. This is fine for me, not however for low end computers.

  1. Loading time should be explored (takes me 2-4 mins to load)
  2. 12-20GB ram usage

Some options were used in the JVM for string and did not work. I ran application on JRE 20 and still was the same points. Upon profiling it tends to be the strings in the tables when looking at memory of the heap on a live application.

  1. Some solutions would be lazy loading, and only load what's as its needed with weak referencing
  2. Use weak references for things that should be collected, however initialization or load checks would have to be placed in.... Example is when I am idle totally on application, the data on most tabs should be able to be garbage collected. This can be programmed with a idle timer, and optional configuration settings for the user. Granular control could be implemented even on collapsed stockpiles and groups. If opened, check if data is null or not initialized, initialize. Start idle timer. Further investigation could be into that the frequency of use could be added to the algorithm idle timer increase under the user if they selected it.
  3. Upgrade to Java 9+ (the long term route) which has the ability to implement string compact strings, since the compressed string java argument wont work though it should in JRE 8.

By setting up a system where weak references are used, when nothing is references one of the list of strings, it will become eligible for GC, however that means all the strings in the table or list must also not be hard references anywhere and be weakly references. Java has a Weak List/Maps as well as. I will provide profiling data from jprofile to this thread in about 2-3 weeks. Sometime around May15-25th.

Here are some lite primers for anyone following, not all inclusive design Tanique more of the basic what and how. image image

References Baeldung. (2022, September 3). Guide to WeakHashMap in Java. Baeldung. https://www.baeldung.com/java-weakhashmap

Dąbrowski, M. (2022, November 28). Strong, Weak, Soft, and Phantom References in Java. Baeldung. https://www.baeldung.com/java-reference-types

Difference between compact strings and compressed strings in Java 9. (n.d.). Stack Overflow. https://stackoverflow.com/questions/44178432/difference-between-compact-strings-and-

compressed-strings-in-java-9 Java: difference between strong/soft/weak/phantom reference. (n.d.). Stack Overflow. https://stackoverflow.com/questions/9809074/java-difference-between-strong-soft-weak-phantom-reference

WeakReference (Java Platform SE 8 ). (2023, April 5). https://docs.oracle.com/javase/8/docs/api/java/lang/ref/WeakReference.html

Mr00Anderson commented 1 year ago

After we did some review, it was determined that keeping the history of journal and wallet transaction was causing the profile to bloat to 1.2 GB and in memory 13GB or so. It does not appear that the strings from stockpiles was actually the culprit and it was just the 500k lines of history. So turning off the history keeps this from bloating. Manual pruning works, but requires software or a careful hand in editing XML files.