3 ms·
I have a JavaFX app which is consuming far more memory than the heap allocates... even when I set Xmx. For example, with java -Xmx64m I can see that the app run
by brabel 7y ago
I have a JavaFX app which is consuming far more memory than the heap allocates... even when I set Xmx. For example, with java -Xmx64m I can see that the app runs just fine, but it still consumes over 200MB according to the OS (checked with htop and with Mac's System Monitor). Does anyone know a tool to help find out why the JVM is holding on to so much memory beyond the heap, or how to make the JVM use less native memory?
I've found out that vmmap (as shown here[1]) is only a little helpful, as it has so much info I can't really make sense of it... and I also found this[2] answer on StackOverflow that was very helpful as it lets me see the native memory allocation by the JVM... but all I know now is that less than half of my JVM memory consumption is the actual heap: the rest is thread stacks (huge for JavaFX - around 50MB for my app), GC-allocated memory and around 25MB of class definitions!
[1] https://plumbr.io/blog/memory-leaks/why-does-my-java-process-consume-more-memory-than-xmx https://plumbr.io/blog/memory-leaks/why-does-my-java-process...
[2] https://stackoverflow.com/a/30941584/1007991 https://stackoverflow.com/a/30941584/1007991
- srvaroa 7y agoA good way for getting a deeper insight of JVM memory usage beyond heap is -XX:NativeMemoryTracking=detail
- wlkr 7y agoHave you tried VisualVM [0,1,2]? I've found it pretty easy to use. I'm not sure how helpful it will be for native memory, however (likely not much!). [0]: https://visualvm.github.io/ https://visualvm.github.io/ [1]: https://en.wikipedia.org/wiki/VisualVM https://en.wikipedia.org/wiki/VisualVM [2]: https://visualvm.github.io/ https://visualvm.github.io/
- jillesvangurp 7y agoAnother tool for this is jvmtop, https://github.com/patric-r/jvmtop https://github.com/patric-r/jvmtop I've used this a couple of times to profile running servers. Not perfect but it lets you profile memory and cpu usage. Visualvm is a PITA to get working over ssh.
- brabel 7y agoThat's the oldest tool in the Java dev toolbox... but it only shows heap usage and metaspace. Also, after Java 9+ they seem to have retired jvisualvm and the tool to use now is https://wiki.openjdk.java.net/display/jmc/Main https://wiki.openjdk.java.net/display/jmc/Main
- kevinherron 7y agoVisualVM is still being developed: https://visualvm.github.io https://visualvm.github.io
- brabel 7y agoYeah, I saw that... last release was just a few days ago... I thought that since the Java standard distribution stopped shipping it, it would just die off and JMC would become the new standard tool... knowing that it's still alive makes me very happy, especially after Oracle fired the whole team working on JMC[1] immediately after open-sourcing it.. However, in the VisualVM downloads page[2], they say: "VisualVM has also been distributed in Oracle JDK 6~8 as Java VisualVM. It has been discontinued in Oracle JDK 9. See the Upgrading Java VisualVM page to learn how to upgrade to the latest VisualVM." That's confusing wording: it sounds like they did "discontinue" something... I think they mean it just stopped being bundled with the JVM, which is not the same thing as discontinuing it. [1] https://www.infoq.com/news/2018/06/open-source-jmc/ https://www.infoq.com/news/2018/06/open-source-jmc/ [2] https://visualvm.github.io/download.html https://visualvm.github.io/download.html