My tomcat Java 8 application is running with 24GB XMX on 32GB Virtual machine with G1 GC. It processes large files. Files have size of 5-7 GBs.
After deployment during the processing of one of such files VM is starting to use > 90% of allocated memory. This value never drops and only increases despite the processing was over and Java has a ton of unused heap (~7GBs).
It however dropped once we triggered Full GC from the VisualVM. We've also noticed the application had only one Major GC during its lifetime - which was triggered with Full GC from VisualVM.
It's clear that java has committed heap and don't wan't to give it back to OS.
Question is: how to get rid of such behavior and return memory back to OS(looks like G1 doesn't do it until java 12) or how to investigate why remaining 8 GBs of non-heap space are full? seems like I can't do it with VisualVM.