Unity 的垃圾收集器——为什么是非分代和非压缩的?
Unity's garbage collector - Why non-generational and non-compacting?
我刚刚在 Unity's docs 中读到
Unity’s garbage collection – which uses the Boehm GC algorithm – is non-generational and non-compacting. “Non-generational” means that the GC must sweep through the entire heap when performing a collection pass, and its performance therefore degrades as the heap expands. “Non-compacting” means that objects in memory are not relocated in order to close gaps between objects.
你们中有人知道或假设为什么 Unity 中止使用标准的 .Net GC 生成和压缩吗?我做了一些测试,我真的很惊讶甚至来自 LOH 的对象都在第 0 代并且可能 GC 试图用小对象收集它们。
您注重细节,所以这里有一个您应得的细节故事。
Unity 和 Mono 于 2008 年初宣布合作,当时 Unity 许可了 Mono 运行时(GPL 涵盖开源使用)以便嵌入它。而 Boehm GC 是当时 Mono 中的主要 GC。
时间过去了,Mono 4.x/5.x 默认使用具有 generational/compacting 特性的 SGen GC。但是,Unity 不想再次支付许可费用。因此,您看到的文档保持原样。
微软在2016年收购了Xamarin,从而获得了Mono核心资产的控制权。它在 MIT 下重新发布了代码库,从而永远解决了许可问题。 Unity 加入 .NET 基金会并开始与 Microsoft/Xamarin 合作,将最新的 Mono 运行时整合到游戏引擎中。
这项工作仍在进行中,应该很快就会成熟(目前是一项实验性功能)。
顺便说一句,Unity 还不能使用标准的 .NET GC。微软并没有在.NET Framework 中开源它的GC,而是在.NET Core 中开源了一个版本。该 GC 与 Mono 的不同,并且需要更多的努力才能嵌入到 Unity 中。我想这就是为什么现在选择集成 Mono 5 的原因。也许将来 Unity 会迁移到 .NET Core GC。
部分活动可以在 .NET timeline 中找到。
我刚刚在 Unity's docs 中读到
Unity’s garbage collection – which uses the Boehm GC algorithm – is non-generational and non-compacting. “Non-generational” means that the GC must sweep through the entire heap when performing a collection pass, and its performance therefore degrades as the heap expands. “Non-compacting” means that objects in memory are not relocated in order to close gaps between objects.
你们中有人知道或假设为什么 Unity 中止使用标准的 .Net GC 生成和压缩吗?我做了一些测试,我真的很惊讶甚至来自 LOH 的对象都在第 0 代并且可能 GC 试图用小对象收集它们。
您注重细节,所以这里有一个您应得的细节故事。
Unity 和 Mono 于 2008 年初宣布合作,当时 Unity 许可了 Mono 运行时(GPL 涵盖开源使用)以便嵌入它。而 Boehm GC 是当时 Mono 中的主要 GC。
时间过去了,Mono 4.x/5.x 默认使用具有 generational/compacting 特性的 SGen GC。但是,Unity 不想再次支付许可费用。因此,您看到的文档保持原样。
微软在2016年收购了Xamarin,从而获得了Mono核心资产的控制权。它在 MIT 下重新发布了代码库,从而永远解决了许可问题。 Unity 加入 .NET 基金会并开始与 Microsoft/Xamarin 合作,将最新的 Mono 运行时整合到游戏引擎中。
这项工作仍在进行中,应该很快就会成熟(目前是一项实验性功能)。
顺便说一句,Unity 还不能使用标准的 .NET GC。微软并没有在.NET Framework 中开源它的GC,而是在.NET Core 中开源了一个版本。该 GC 与 Mono 的不同,并且需要更多的努力才能嵌入到 Unity 中。我想这就是为什么现在选择集成 Mono 5 的原因。也许将来 Unity 会迁移到 .NET Core GC。
部分活动可以在 .NET timeline 中找到。