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.
分享到:
相关推荐
The Garbage Collection Handbook The Art of Automatic Memory Management, Jones, Hosking, Moss, 2012
The Garbage Collection Handbook:The Art of Automatic Memory Manage
The Garbage Collection Handbook 内存管理,垃圾收集,GC
The Garbage Collection Handbook The Art of Automatic Memory Management 英文epub
The Garbage Collection Cookbook 垃圾回收算法手册
The Garbage Collection Handbook 关于垃圾回收器算法的书籍,非常不错
Garbage Collection Algorithms For Automatic Dynamic Memory Management
在JVM5.0中调配Garbage Collection 在JVM5.0中调配Garbage Collection 在JVM5.0中调配Garbage Collection
Java Garbage Collection Basics
严蔚敏数据结构与算法▲课本算法实现
WP-Understanding Java Garbage Collection
Java Garbage Collection Study java 垃圾回收学习
Lock-free Parallel Garbage Collection
12.6.5 “Garbage collecting the world” 12.6.6 网络对象 12.6.7 带权引用计数 12.6.8 世代引用计数 12.7 对actor进行垃圾收集 12.7.1 Halstead算法 12.7.2 标记算法 12.7.3 逻辑上集中式的收集器 12.8 引文注记
The Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide describes the garbage collection methods included in the Java HotSpot Virtual Machine (Java HotSpot VM) and ...
此书主要讲解了内存动态分配算法和垃圾回收算法。希望对需要的朋友有所帮助。
This paper presents a new garbage collection scheme for flash memory based storage systems that focuses on reducing garbage collection overhead, and improving the endurance of flash memory. The scheme...
JDK9-JSE-HotSpot Virtual Machine Garbage Collection-53