.NET和Java的垃圾回收器 [英] .Net vs Java Garbage Collector

查看:167
本文介绍了.NET和Java的垃圾回收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道Java和.NET垃圾收集器之间的主要区别是什么?网络搜索没有透露太多,这是在测试想出了一个问题。

Does anyone know the major differences between the Java and .Net garbage collectors? A web search has not revealed much, and it was a question that came up in a test.

推荐答案

的差异是在CLR(净)的GC和JVM GC而非语言本身之间。
双方如有变更及其行为的规范松动,让这又不影响程序的正确性进行更改。

The difference is between the CLR (.Net) GC and the JVM GC rather than the languages themselves. Both are subject to change and the specification of their behaviour loose to allow this to be changed without it affecting the correctness of programs.

有很大程度上是由于净正在设计从Java(和其他GC的平台)的发展经验教训的一些历史差异。在下面的不假定净之一是在某些方面优越,因为它包括从一开始的功能,它只是后来来的结果。

There are some historical differences largely due to .Net being designed with lessons from the evolution of the java (and other gc based platforms). In the following do not assume that the .Net one was in some way superior because it included functionality from the beginning, it is simply the result of coming later.

有一个显着的公开可见的区别是,MS GC暴露了其代性(通过GC API),这是有可能在一段时间保持正确的,因为这是采取基于行为的,大多数程序表现出明显的方法:最分配是非常短暂的。

A notable publicly visible difference is that the MS GC exposes its generational nature (via the GC api) this is likely to remain true for some time since this is an obvious approach to take based on the behaviour that most programs exhibit: Most allocations are extremely short lived.

初​​始JVM的没有代的垃圾收集器虽然很快被添加此功能。
通过<击>太阳实施的第一代收藏家甲骨文等公司往往是标记和清除。人们认识到,一个标记 - 清除紧凑的方式会导致更好的内存位置证明额外的复制开销。 CLR的运行时推出这一行为。

Initial JVM's did not have generational garbage collectors though this feature was swiftly added. The first generational collectors implemented by SunOracle and others tended to be Mark and Sweep. It was realized that a mark-sweep-compact approach would lead to much better memory locality justifying the additional copying overhead. The CLR runtime debuted with this behaviour.

之间的差异<击>孙甲骨文和微软的GC实施精神是可配置之一。

A difference between SunOracle's and Microsoft's GC implementation 'ethos' is one of configurability.

<击>孙的提供了一个广大的选项(在命令行),以调整GC的方面或不同的模式之间切换。许多选项是-X或-XX来表明他们缺乏在不同版本或供应商的支持。相比之下,CLR提供旁边没有配置性;您的唯一真正的选择是使用服务器或客户端收藏家它优化吞吐量的诗句分别等待时间。

Sun's provides a vast number of options (at the command line) to tweaks aspects of the GC or switch it between different modes. Many options are of the -X or -XX to indicate their lack of support across different versions or vendors. The CLR by contrast provides next to no configurability; your only real option is the use of the server or client collectors which optimise for throughput verses latency respectively.

在GC策略积极的研究是在两个公司持续(在开源实现)中的最近的GC实现正在使用当前的方法是每线程伊甸区域(提高局部性和允许伊甸收集可能不导致完全停顿)以及pre-tenuring办法,这应尽量避免将某些分配到伊甸园产生。

Active research in GC strategies is ongoing in both companies (and in open source implementations) current approaches being used in the most recent GC implementations are per thread eden areas (improving locality and allowing the eden collection to potentially not cause a full pause) as well as pre-tenuring approaches, which try to avoid placing certain allocations into the eden generation.

这篇关于.NET和Java的垃圾回收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆