问题描述
JVM 用于抛出java.lang.OutOfMemoryError:GC 开销限制超出"的采样时间是多少?我知道您可以使用参数 GCTimeLimit 和 GCHeapFreeLimit 控制 98% 和 2%,但是采样时间是多少?
What is the sampling time JVM uses to throw 'java.lang.OutOfMemoryError : GC overhead limit exceeded'? I know you can control 98% and 2% with parameters GCTimeLimit and GCHeapFreeLimit but whats the sampling time?
推荐答案
来自 Java SE 6 HotSpot[tm] 虚拟机垃圾收集调优
以下
GC 时间过长和 OutOfMemoryError
Excessive GC Time and OutOfMemoryError
如果太多,并发收集器将抛出 OutOfMemoryError时间花在垃圾收集上:如果超过 98%总时间花在垃圾收集上,不到 2%堆被恢复,OutOfMemoryError 将被抛出.此功能旨在防止应用程序长时间运行一段时间内几乎没有进展,因为堆是太小.如有必要,可以通过添加选项-XX:-UseGCOverheadLimit到命令行.
The concurrent collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line.
该策略与并行收集器中的策略相同,不同之处在于执行并发收集所花费的时间不计入98%的时间限制.换句话说,只有在应用程序停止计入过多的 GC 时间.这样的集合通常是由于并发模式故障或显式收集请求(例如,调用 System.gc()).
The policy is the same as that in the parallel collector, except that time spent performing concurrent collections is not counted toward the 98% time limit. In other words, only collections performed while the application is stopped count toward excessive GC time. Such collections are typically due to a concurrent mode failure or an explicit collection request (e.g., a call to System.gc()).
结合下面的一段
显式垃圾最常见的用途之一收集发生在 RMI 分布式垃圾收集 (DGC) 中.使用 RMI 的应用程序引用其他虚拟机中的对象.垃圾不能在这些分布式应用程序中收集偶尔收集本地堆,因此 RMI 强制进行完整收集定期.这些收集的频率可以控制与属性.例如,
One of the most commonly encountered uses of explicit garbage collection occurs with RMIs distributed garbage collection (DGC). Applications using RMI refer to objects in other virtual machines. Garbage cannot be collected in these distributed applications without occasionally collection the local heap, so RMI forces full collections periodically. The frequency of these collections can be controlled with properties. For example,
java -Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000
指定每小时一次的显式收集,而不是默认的每小时一次分钟.但是,这也可能导致某些对象花费更长的时间被回收.这些属性可以设置为 Long.MAX_VALUE使显式集合之间的时间有效地无限,如果DGC的时效性没有上限活动.
-Dsun.rmi.dgc.server.gcInterval=3600000
specifies explicit collection once per hour instead of the default rate of once per
minute. However, this may also cause some objects to take much longer
to be reclaimed. These properties can be set as high as Long.MAX_VALUE
to make the time between explicit collections effectively infinite, if
there is no desire for an upper bound on the timeliness of DGC
activity.
似乎意味着确定 98% 的评估期为一分钟,但它可能可以在 Sun 的 JVM 上通过正确的定义进行配置.
Seems to imply that the evaluation period for determining the 98% is one minute long, but it might be configurable on Sun's JVM with the correct define.
当然,其他解释也是可能的.
Of course, other interpretations are possible.
这篇关于超出 GC 开销限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!