Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java/Tomcat heap size question

I am not a Java dev, but an app landed on my desk. It's a web-service server-side app that runs in a Tomcat container. The users hit it up from a client application.

The users constantly complain about how slow it is and the app has to be restarted about twice a week, cause things get really bad.

The previous developer told me that the app simply runs out of memory (as it loads more data over time) and eventually spends all its time doing garbage collection. Meanwhile, the Heap Size for Tomcat is set at 6GB. The box itself has 32GB of RAM.

Is there any harm in increasing the Heap Size to 16GB?
Seems like an easy way to fix the issue, but I am no Java expert.

like image 797
AngryHacker Avatar asked Dec 28 '22 00:12

AngryHacker


2 Answers

You should identify the leak and fix it, not add more heap space. Thats just a stop gap.

You should configure tomcat to dump the heap on error, then analyze the heap in one of any number of tools after a crash. You can compute the retained sizes of all the clases, which should give you a very clear picture of what is wrong.

Im my profile I have a link to a blog post about this, since I had to do it recently.

like image 52
hvgotcodes Avatar answered Dec 30 '22 13:12

hvgotcodes


No, there is no harm in increasing the Heap Size to 16GB.

like image 30
Sam Colton Avatar answered Dec 30 '22 13:12

Sam Colton