views:

77

answers:

2

I have a high volume Java application that handles a consistent load of 50000msgs/sec. It is tuned for high throughput using the following settings:

-Xmx3g -Xms3g -XX:NewSize=2g -Xss128k -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=90 -XX:+UseParallelGC -XX:ParallelGCThreads=12 -XX:+UseParallelOldGC -XX:+HeapDumpOnOutOfMemoryError

I am finding that the young GC times steadily creeps up from 50ms when it starts to 200ms by the end of the day, although the frequency of GC runs remains the same.

If I try the same run using the ParNewGC collector, the GC times goes up at a much faster rate. Does anyone have any thoughts on this problem?

+1  A: 

If you have a memory leak, or an in-memory cache that is gradually using more and more memory, these would have the effect of causing the GC to do more work tracing the reachable objects.

Stephen C
I have checked that there is no memory leak, the graphs of young,tenured and old generations are all periodic.
Java IsSlow
A: 

It may be a combination of several factors:

  • A real memory leak. ( Objects are still referenced by accident)
  • More objects, or maybe a different distribution of the objects between the gc-pools.
  • The heap is larger. Plot the gc-time and the heap size.
  • Memory fragmentation. On OS level and/or the java heap, depending on the jvm.

Why don't you plot the number of objects, heap size and gc-time. (using a tool, or by quering MBeans) A plot should tell you the trend; increasing, decreasing or linear, and will help you to determine if there is a leak. If possible, also dump some statistics from your program, like the number of processed messages or active sessions etc.

Is it a real problem since your messages are not processed during gc?. Try the concurrent mark and sweep gc...

* -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
KarlP
I am fairly certain this is not a memory leak because I can see the young gen oscillate from 100MB to 2GB, periodically. Pretty much the entire load of new obejcts are cleared out in young gen itself. If I set a smaller young gen heap size then I wouldn't be able to handle a sudden flood of messages.
Java IsSlow
I have tried -XX:+UseConcMarkSweepGC -XX:+UseParNewGC and the problem only got worse. I did consider memory fragmentation, but I am not sure how to ascertain if this is the cause.
Java IsSlow
I had to read the gc tuning guide, and it indicates that both parallel gc and even more so concurrent mark and sweep are actually more likely to cause fragmentation. So as it got worse while using concMarkSweep, it might indicate that its actually fragmentation that you are seeing. Try these two tips from the guide and see if it gets better... "Reducing the number of garbage collector threads will reduce this fragmentation effect as will increasing the size of the tenured generation."
KarlP
(I guess you've read this :http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html.)
KarlP