什么触发垃圾收集 [英] What triggers garbage collection
问题描述
HotSpot的垃圾收集已经发展成为一项极其复杂的业务,了解详情。因此你不能得到一个简单的答案;一些触发器是:
- 占用每个对象生成达到阈值;
- 内存分配请求在特定的一代失败;
- 整体堆占用率达到阈值
- occupation of each object generation reaching a threshold;
- a memory allocation request in a specific generation failing;
- overall heap occupation reaching a threshold.
请注意,您甚至没有指定您感兴趣的垃圾收集的类型:有一个次要集合和一个主要 >收集,技术上他们是非常不同的。您还没有指定您想要的垃圾收集器:HotSpot有四个垃圾收集器供您选择。
如果您是Java初学者,是a)在日常编程中,不要担心;和b)如果你想学习,你必须深入挖掘。
I know what all gets garbage collected. But what exactly tells JRE that it is time for garbage collection? Is it like some event or time interval?
HotSpot's garbage collection has grown into an exceedingly complex business, which even its creators struggle to understand in full detail. Therefore you can't be given a simple answer; some triggers are:
Note that you haven't even specified what kind of garbage collection you are interested in: there is a minor collection and a major collection, and technologically they are very different. You have also not specified which Garbage Collector you have in mind: HotSpot has four of them to choose from.
If you are a beginner with Java, the best advice to give is a) in day-to-day programming, don't worry about it; and b) if you want to learn, you'll have to dig deep.
这篇关于什么触发垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!