Frequent full GC with empty heap

2019-06-02 07:33发布

问题:

I've got a GC log file that shows frequent full GC when the heap is empty (every 30 mins initially, then 20, 10, 5 up to few events a minute. At some point, though, I can see a sudden increase in the heap usage (I'd imagine at the moment when users start connecting to my application) and full GC events start to take place less freqently. I can't think of a reason why this may happen.

I'm using Oracle Vm 1.6, and my startup script is:

java -XX:+HeapDumpOnOutOfMemoryError \
     -Xmx7500m \
     -XX:HeapDumpPath=../logs \
     -verbose:gc \
     -XX:+PrintGCDetails \
     -XX:+PrintGCTimeStamps \
     -Xloggc:/app/diffusion/Logs/gc.log \
     -Dcom.sun.management.jmxremote \
     -Dcom.sun.management.jmxremote.ssl=false \
     -Dcom.sun.management.jmxremote.authenticate=false \
     -Dcom.sun.management.jmxremote.port=2000 \
     -cp ../lib/diffusion.jar:../etc:../data com.pushtechnology.diffusion.Diffusion $1

回答1:

Try disabling explicit GC, see if it helps : -XX:+DisableExplicitGC.

Then, you could collect a few thread dumps to confirm that there is nothing really running in the app when the heap is empty.