Question about Java / Tomcat heap

I am not a Java developer, but the application has landed on my desk. This is a web service server application that runs in a Tomcat container. Users hit it from the client application.

Users constantly complain about how slowly this happens, and the application needs to be restarted about twice a week, because everything is getting really bad.

The previous developer told me that the application simply ran out of memory (since it loads more data over time) and ultimately spends all its time collecting garbage. Meanwhile, the heap size for Tomcat is set at 6 GB. The box has 32 GB of RAM.

Is there any harm in increasing the heap size to 16 GB?
This seems like an easy way to fix the problem, but I'm not a Java expert.

+4
source share
5 answers

No, there is no harm in increasing the heap size to 16 GB.

+2
source

You should identify the leak and fix it, not add more heaps. This is just a stop.

You must configure tomcat to clear the heap error, and then analyze the heap in one of several tools after the crash. You can calculate the saved sizes of all clans, which should give you a very clear idea of ​​what's wrong.

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

+5
source

The previous developer told me that the application just ran out of memory (as it loads more data over time)

This is like a memory leak, a serious error in the application. If you increase the amount of memory available from 6 to 16 gigabytes, you still have to restart the application, only less often. Some experienced developers should take a look at a bunch of the application while it is running (see hvgotcodes Tips) and fix the application.

+1
source

To solve these problems, you must perform performance testing. This includes processor and memory analysis. JDK (6) bundles a tool called VisualVM, on my Mac OS X machine this is by default called "jvisualvm". It's free and bundled, so this is the place to start.

Next is NetBeans Profiler (netbeans.org). It does more memory and processor analysis. It's also free, but a little trickier.

If you can spend money, I highly recommend YourKit (http://www.yourkit.com/). It is not very expensive, but it has many built-in diagnostics that make it easy to find out what is happening.

The only thing you cannot do is assume that simply adding more memory will fix the problem. If this is a leak, adding more memory may cause it to work very much longer between reboots.

+1
source

I suggest you use a profiling tool like JProfiler, VisualVM, jConsole, YourKit, etc. You can take a bunch of dumps from your application and analyze which objects ate memory.

+1
source

Source: https://habr.com/ru/post/1342166/


All Articles