Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java garbage collection and atomic events/stop gc pauses interrupting a sequence of functional calls

I have a complex large multithreaded application to which I am introducing new functionality.

I have added a call to a piece of specialist hardware (via a vendor supplied JNI lib). However before that (very fast) function is called some work is done beforehand to populate the data structure sent to it.

However the GC profile of the application is very choppy/bad and it seems that some of these population steps are being interrupted by GC. This matters because time needs to be kept constant or as constant as possible between the first of these events and the hand off to the hardware resource.

Is there a way to say, "sychronise for GC", these operations so that they won't be held up during stop the world GC pauses?

Using a 64bit 1.7 JDK on RHL5.5

Thanks

like image 982
easytiger Avatar asked Mar 26 '13 11:03

easytiger


1 Answers

If it is in-fact during the full garbage collection you are experiencing the issues, then the question is what can you do to bring down the frequency of these full garbage collection sweeps.

First, try and analyse what circumstances triggers these full sweeps, are you running low on heap space in general? And if so, why are you frequently running low on heap (are there a potential leak somewhere?)

Also, during minor (the faster) garbage collections, objects are moved from the young generations (eden and survivor 1) to survivor 2. If it doesn't fit in survivor 2, they will be moved to tenured, if there isn't enough space in tenured, you trigger a full sweep. So, if your young generations are large, and you have a certain amount of long running objects, this might cause issues.

In the end of the day, you have to analyse it. Profile you application, and determine when and why you are seeing full garbage collections, and then tune your application to make them less frequent or potentially ensure that the are so infrequent you can "control" when they happen.

like image 180
JustDanyul Avatar answered Sep 19 '22 00:09

JustDanyul