2

I'm experiencing repeated Full GCs even when the heap is not fully used.

This is how the gc logs look like: http://d.pr/i/iFug (the blue line is the used heap and the grey rectangles are Full GCs).

It seems to be a problem similar to the one posted in this question: Frequent full GC with empty heap

However, that thread didn't provide any actual answers to the problem. My application does uses RMI, and the production servers are indeed using 1.6 before the Upgrade 45 that increased GC intervals from 1 min to 1 hour (http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/relnotes.html). However, from the rest of the log, I can't see that Full-GC-every-1-min pattern.

What could possibly be causing this?

2 Answers 2

1

Most likely the cause is you have reached the current size of the heap. The size of the heap is smaller than the maximum you set and is adjusted as the program runs.

e.g. Say you set a maximum of 1 GB, the initial heap size might be 256 MB, and when you reach 256 MB it performs a full GC, after this GC it might decide that 400 MB would be a better size and when this is reach a full GC is performed etc.


You get a major collection when the tenured space fills or fails to find free space. Eg if it is fragmented.

You also get full collections if your survivor spaces are too small.

In short, the most likely cause is the gc tuning parameters you used. I suggest you simplify your tuning parameters until your system behaves in a manner you expect.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm starting the JVM with the same min and max heap, so it can't be it. I'd love to try tunning the GC, but unfortunately this happened in production and I'm being able to reproduce it in a test environment.
0

As noted in the linked thread, disable explicit GC and see if the FullGC pattern occurs again : -XX:+DisableExplicitGC. The RMI code may be triggering explicit GC in given interval, which may not be desirable in some cases.

If the FullGCs still occur, I would take thread dumps and possibly a heap dump to analyze the issue.

Also, use jstat to see the occupation of Eden, Survivor, OldGen spaces.

2 Comments

That could work, but what would be the side effects? I'd love to reproduce this in a testing environment, but I'm not being able to.
There should not be any side effects, it is widely discouraged to call System.gc() - this may harm the performance, so it is only advisable to use -XX:+DisableExplicitGC and let the GC do the work. You basically use this flag as a protection from rogue libraries/code that is trying to trigger explicit GC.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.