Our company has a Unix machine with a tomcat server inside, I, the webApp programmer using spring and vuejs, create the .war to be fed to the Tomcat to have it uploaded online and make it reachable via HTTPS;
a bit of history:
Initially there were only 5 wars in this machine divided into: WebApp and Rest-Api with Job Scheduled (some written via Spring-boot Scheduled others via Quartz and others .war instead via spring-boot and Vuejs and/or vanilla javascript) is happened that for work reasons the wars from 5 have passed to 17. (always divided as written above) It happens that every 3 days the Tomcat server crashes and doesn't work anymore, analyzing the logs the reason why it crashes and doesn't works anymore is due to this "GC overhead limit exceeded" error and every time we restart tomcat, it writes in the catalina.out log a "full dump of the 64 bit Java HotSpot(TM) Server VM thread" thanks to the ycrash community I was able not only to analyze the dump and do further research to better understand why this error is generated and in my research I came across a tool called JProfile and I started using it
Current situation:
After several days of analysis with the JProfile tool I can't go on or rather many questions come into my head and I can't find an answer for example:




QnA
It is normal memory reaching 2GB if you are storing large data in your JVM. Also, there are JVM setting which sets the minimum and maximum memory allocated to your program.
Unfortunately, I cannot answer it for you due to not understanding how your program works. You might need to look through your documentation or the person developed it.
Instead of focusing that, would rather focus on a more general level. Here is some example
Scenarios
High memory, low instance count
JVM detected that
org.jboss.weld.annotated.enhanced.jlris still needed thus it stored them. The instance count is low now doesn't mean it won't be high because certain event will triggered it and program will allocate more instance for it to process.Low memory, high instance count
org.jboss.weld.util.collectionsuses low memory, but certain event triggered it and program need to allocate instance to it for processing.In summary, that's why you could see some instance count is high but memory low and instance count low but memory high which against the theory
high memory = high instance count
or
low memory = low instance count
Additional: Java have garbage collector which removes unused variable which helps make works simple. For example, we do not need to clear some variables (probably have size of 10 million) like list or array.
My solution to your crashing is
mySql.close();