`
xuemo
  • 浏览: 14832 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Garbage Collection

阅读更多

13.1 Detecting Garbage Collection Problems
       A full garbage collection event pauses all threads in the JVM. Nothing happens during the pause. If this
pause takes more than a few seconds it will become noticeable.
The clearest way to see if this is happening is to run jstat. The following command will produce a log of
garbage collection statistics, updated each ten seconds.
        jstat -gcutil <pid> 10 1000000


      The thing to watch for is the Full Garbage Collection Time. The difference between the total time for each
reading is the time the system spends time paused. If there is a jump more than a few seconds this will not
be acceptable in most application contexts.

 

13.2 Garbage Collection Tuning
The Sun core garbage collection team has offered the following tuning suggestion for virtual machiens
with large heaps using caching:
java ... -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC
-XX:NewSize=<1/4 of total heap size> -XX:SurvivorRatio=16
The reasoning for each setting is as follows:
• -XX:+DisableExplicitGC - some libs call System.gc(). This is usually a bad idea and could explain
some of what we saw.
• -XX:+UseConcMarkSweepGC - use the low pause collector
• -XX:NewSize=1/4 of total heap size -XX:SurvivorRatio=16

 

13.3 Distributed Caching Garbage Collection Tuning
Some users have reported that cenabling distributed caching auses a full GC each minute. This is an issue
with RMI generally, which can be worked around by increasing the interval for garbage collection. The
effect that RMI is having is similar to a user application calling System.gc() each minute. In the settings
above this is disabled, but it does not disable the full GC initiated by RMI.
The default in JDK6 was increased to 1 hour. The following system properties control the interval.
-Dsun.rmi.dgc.client.gcInterval=60000
-Dsun.rmi.dgc.server.gcInterval=60000
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4403367 for the bug report and detailed instructions
on workarounds.
Increase the interval as required in your application.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics