0

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

image gallery: memory summary thread

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:

  1. It is normal that the memory always reaches 2GB;
  2. Is it normal that there are almost more than 80 threads in blocked state?
  3. How does Java.util have such a high value? Java Utili Exapand
Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
  • What JVM parameters did you specify? It could possibly limit the amount of memory you could use. 80 blocked threads sounds like some sort of deadlock where they all need some resource that they cant get. As for why theres a lot of HashMap$Node, I think it pertains to when you try to busy-spin and contend for a lock. I recently asked a question about [that](https://stackoverflow.com/a/75682761/16034206) – experiment unit 1998X Mar 16 '23 at 08:07

1 Answers1

2

QnA

  1. It is normal that the memory always reaches 2GB

    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.

  2. Is it normal that there are almost more than 80 threads in blocked state

    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.

  3. How does Java.util have such a high value

    Instead of focusing that, would rather focus on a more general level. Here is some example

    enter image description here

    Scenarios

    1. High memory, low instance count

      JVM detected that org.jboss.weld.annotated.enhanced.jlr is 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.

    2. Low memory, high instance count

      org.jboss.weld.util.collections uses 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

  1. You might need to allocate more RAM.
  2. Please estimate what is the minimum and maximum memory for your program
  3. Please make sure there is no memory leakage. For example, When you establish a connection to your database, make sure to close it, e.g. mySql.close();
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Chan
  • 61
  • 8
  • thank you very much for the answer now let's try to increase the memory via the Xmx flag and we will give more ram to the machine then as regards the connection to the db we use the JDBCTemplate to make queries, I think it closes the mysql connections by itself – lorenzo cavalieri Mar 16 '23 at 09:57