Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Garbage Collection stalls all Java processes

We're running multiple instances of a server process on one linux box. The box has 8 cores and 16gb of RAM. I'm starting up each process with the -Xincgc option, using Java 1.6.

We have various timers instrumented throughout the application that track the time to complete various tasks. When garbage collection happens, I notice that every java process on the box prints out that whatever task it was running at the time was slow.

It's not stalling for a long time, maybe 100-300ms or so, but latency is a huge factor for this. It's also not stalling constantly, just periodically.

When garbage collection is happening does it stop any java process from getting any time? If so, is there any way around this? Should I be using different GC options?

UPDATE:

Just to be clear, I'm not worried about one process stalling while GC is happening. I can tweak settings or optimize for that case. I'm just wondering why EVERY running Java process seems to stall at the same time when I thought they were more or less independent.

like image 472
Guaranteed Avatar asked Feb 23 '12 18:02

Guaranteed


1 Answers

Java v 1.6 is supposed to be smart and work out which kind of GC is the best.

I'd recommend reading this: Garbage collection in Java 6

Summary: try either of these (but not both):

  • -XX:+UseParallelGC
  • -XX:+ExplicitGCInvokesConcurren
like image 106
andy boot Avatar answered Nov 14 '22 22:11

andy boot