Long in-app GC sessions

I am currently running an application that requires a maximum heap size of 16 GB.

I am currently using the following flags to handle garbage collection.

-XX\:+UseParNewGC, -XX\:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=50, -XX\:+DisableExplicitGC, -XX\:+PrintGCDateStamps, -XX\:+PrintGCDetails, -Xloggc\:/home/user/logs/gc.log 

However, I noticed that during some garbage collectors, the application blocks for a few seconds, and then continues - this is completely unacceptable, since it is a game server.

From my garbage collection logs can be found here .

Any advice on what I should change to reduce these long pauses would be greatly appreciated.

+6
source share
4 answers

Any advice on what I should change to reduce these long pauses would be greatly appreciated.

Most likely, CMS GC will not be able to cope with the amount of garbage created by your system. But the work that the GC should do is actually more closely related to the amount of unnecessary garbage that your system saves.

So...

  • Try to reduce the actual memory usage of your application; for example, not caching so much material or reducing the size of your "world."
  • Try to reduce the speed with which your application creates garbage.
  • Switch to a machine with more cores so that more cores are available if necessary to run parallel GC threads.

To the mystical:

Yes, looking back, it would be better to implement a server in C ++. However, we do not know anything about the "game." If this is due to a complex world model with complex heterogeneous data structures, then its implementation in C ++ may mean that you replace the β€œGC pause” problem with the problem that the server is constantly crashing due to problems with the way it manages its structure data .

+4
source

Looking at your magazines, I do not see long pauses. But young HA is very frequent. The pace of progress is very low, though (most of the garbage is cleaned up by the young GC, as it should). At the same time, your previous use of space is low.

By the way are we talking about minecraft server?

To reduce the incidence of young GC, you must increase its size. I suggest starting with -XX:NewSize=8G -XX:MaxNewSize=8G

For such a large young space, you must also reduce the size of the space for survivors -XX:SurvivorRatio=512

GC tuning is a trial and error path, so you may need a few more iterations and tuning.

You can find some useful articles on the mu blog.

+2
source

I'm not a Java garbage collector, but it looks like you're doing the right thing using the parallel collector (UseConcMarkSweepGC flag), assuming the server has multiple processors. Follow the troubleshooting tips at http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#cms . If you already have one, let us know what happened when you tried them.

+1
source

What version of java are you using? http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html To better try to minimize the use of instance variables in the class. It will be better to execute local variables than instance variables. This helps in achieving performance and security against synchronization issues. At the end of the work, before exiting the program, always reset the used variables if you use instance variables and set them again when necessary. This helps more in improving productivity. In addition, the java version has a good garbage collection policy. It is better to upgrade to a new version if it is hopeless. You can also track pause times in the garbage collector using VisualVm, and you can get more information about when it executes more garbage.

0
source

All Articles