Guaranteed
Guaranteed

Reputation: 153

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.

Upvotes: 7

Views: 7011

Answers (4)

kosa
kosa

Reputation: 66637

when you use -Xincgc, as per this sun documentation

The concurrent low pause collector: this collector is used if the -Xincgc ™ or -XX:+UseConcMarkSweepGC is passed on the command line. The concurrent collector is used to collect the tenured generation and does most of the collection concurrently with the execution of the application. The application is paused for short periods during the collection.

You may need to consider other alternatives like Throughput Collector. Above documentation has good description on when, which collector will be useful.

Upvotes: 3

tom
tom

Reputation: 2745

The problem you are encountering is a 'Full Garbage Collection', also known as a 'Stop the world GC'. When this occurs you java app basicly stops working. Check this thread for some pointers:

Tuning garbage collections for low latency

Upvotes: 2

andy boot
andy boot

Reputation: 11727

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

Upvotes: 3

cjstehno
cjstehno

Reputation: 13984

If you use a tool like JConsole to view your memory activity you will see that garbage collection is generally a weighty activity. You may want to do some profiling to see if there are other bottlenecks involved. Also, most of the garbage collection algorithms have quite a few configuration options available to them.

Lastly, I remember a situation we dealt with quite a while ago led us to find that having your min and max memory settings closer together was helpful (at least in our case). It caused more frequent garbage collection but they were not as intrusive.

Hope this helps.

Upvotes: 0

Related Questions