r/javahelp • • Jun 17 '19

Memory leak on some systems

Hi, taking a break tearing my hair out, hoping for some suggestions.

The particulars:

JavaFX application running as a bundled exe on Java 1.8 (release 212).

Running on mix of windows 10/7. All 64bit.

The issue:

Frequent out of memory crashes on older windows 7's.

This is not a case of higher memory available preventing the crash on newer systems, as monitoring usage through visuamvm indicates that no leak occurs on newer windows 7's, or any windows 10's.

For example, starting the program on a newer windows 10 (or 7) shows a running usage of about 50 mb. Performing an action like clicking a button that loads in a new pane will raise it slightly, and spam clicking the button can spike the usage to 250-400, but as soon as a gc is performed the usage will return to the expected 50.

On older windows 7 (Various Dell Vostros from 2013) the GC's are still performed, but the overhead increases each time - after 20-30 "cycles" of loading in new panes and closing, memory usage is in the GB's and never decreases, even if a manual GC is performed, which tells me resources are not being released.

Windows 7 systems are all updated to the same level, all are running the same java versions -- so I am not sure why this leak only affects some systems. (All are similar performing intel i3's, thought the affected systems have less memory. 6gb vs 8.).

Looking at the heap dumps the items that fail to release are all in com.sun.prism.* -- which I think is tied to the javafx UI, but don't know how to diagnose and fix something like this.

Edit: feel I should clarify when this issue appeared. As code samples will only do so much in an app with 60,000 lines where most basic 'click the button' type functions result in the issue. This did not occur until 'downgrading' to Java 1.8.xx, previously Java 10. The reason for the downgrade was 'administrative insistence' on Pedro DV's excellent JMetro UI theme. The theme itself is not responsible, as the issue occurs identically with or without the theme, it's more the broader move to 1.8 vs 10+. (Also occurs with all 1.8 revisons tested, from 92-212.)

22 Upvotes

5 comments sorted by

8

u/[deleted] Jun 17 '19

I think you've made a good case that it's a bug in Java itself. Open a bug report with Oracle.

That fix (if it happens) won't arrive soon. In the meantime, you need a workaround. If it was my application, I would move to Java 11 and use a different UI theme. According to the JMetro web page, Pedro isn't spending a lot of time on it and has no plans to add support for any other Java version. I would not want my application to be permanently stuck on Java 8.

2

u/MEPETAMINALS Jun 17 '19

Thanks for the response. I'll have to figure something out. Might have an easier time convincing management to buy all new pc's over getting a different skin. Some people really attached to it.

2

u/mentholmeow Jun 17 '19

You could try turning on verbose GC in the commandline options -verbose:gc

1

u/chickenmeister Extreme Brewer Jun 17 '19

When you look at the heap dump, can you see where the unintentionally-retained objects are being referenced from? VisualVM should let you see all references to a particular object. Maybe there is some way to can eliminate that reference in your code, so that the objects can be GCed.

It sounds like it could be a bug in Java 8. If you can't upgrade to a newer version, you could consider trying a different JRE, such as one from Amazon Corretto or Azul.

0

u/[deleted] Jun 17 '19

[deleted]

2

u/MEPETAMINALS Jun 18 '19

Hi, thanks for the in-depth response. Regarding JMetro, it is compatible only to Java 8 due to a good chunk of reorganization between 8-9, particularly with node skin classes, lots of imports fail, and a lot of rewrites would be needed. Could probably get it to work, but not a small undertaking.

All systems are running same build version. (It's a self contained application.)

With your first point, I can split it up pretty easily. For comparison tests I have a very basic version going, no theme (or imports for the theme), so I know it's not responsible, and just a single button that creates a Gridpane with text, nothing fancy. There's some background DB updates going on on a different thread, but I'd think if a leak was occuring there it would happen on all systems.

I'll keep working on it, maybe see if I can convince management to update.