6

I checked current memory behaviour for a Java application and I notice Garbage Collector initially rarely runs but in the long period it continues to run more often, even if I set no limits for max memory usage (server has 8Gb of free ram).

Initially GC runs once every 20 minutes and after 15 hours once a minute, but the application does the same thing and there are no spikes in RAM usage.

Continuing to run GC, it consumes more and more CPU and after 24 hours, CPU usage is at 85% and GC runs every 10 seconds.

Here are snapshot of performances:

Jprofiler run for 14 hours

Jprofiler run for 14 hours

JvisualVM run for the last hour

JvisualVM run for the last hour

JvisualVM - High CPU usage

JvisualVM - High CPU usage

Why GC starts even if memory is very low? It shouldn't start in these situations.

What could be the cause or what should I do to investigate this behaviour?

Jamirow
  • 61
  • 3
  • 1
    Include your GC settings in the question. – Kayaman Nov 17 '17 at 10:41
  • If the CPU usage is at 85%, but you're only getting GC every 10 seconds, it seems like your program has gone crazy and is probably generating a lot of garbage that gets collected in the young generation. – Kayaman Nov 17 '17 at 10:53
  • Maybe in your code/something you use there is `System.gc()` called, try adding `-XX:+DisableExplicitGC`. – Shadov Nov 17 '17 at 10:58
  • 1
    The GC activity is ~0% according to the charts you posted. So what makes you think that it's the GC part that's consuming CPU time? And you should post GC logs instead of charts. – the8472 Nov 17 '17 at 11:18
  • I updated question with chart of bad situation. High CPU usage and GC runs often. – Jamirow Nov 17 '17 at 11:44
  • Well the GC runs often (well, minor collections) because there's a lot of garbage being generated. Then you can see a full GC being run (and the max heap being increased). You should try to find out what's causing the CPU to skyrocket like that, because that's the only "weird" thing here. Everything else seems to work as designed. – Kayaman Nov 17 '17 at 12:05
  • In the new chart *CPU usage* is high. But *GC activity* is still low, You still have not shown that it is actually the GC that is burning CPU cycles. To repeat myself: __Post logs, not charts__. – the8472 Nov 17 '17 at 20:35
  • Log doesn't show anything of relevant for this kind of debugging. No exceptions are shown. I only find classes and threads consuming much resources looking at JVisualVM "Sample" Memory and CPU panels. – Jamirow Nov 19 '17 at 21:04
  • I don't see anything out of the ordinary. Nowhere is GC running "too often", especially if you can't define what "too often" is in your opinion. If you have nothing to support our theory that you have a problem, then I'm concluding that there is no problem and you're imagining things because you don't understand how to read profiling information. – Kayaman Nov 20 '17 at 06:10

0 Answers0