使用垃圾收集有什么缺点? [英] What are the disadvantages in using Garbage Collection?

查看:93
本文介绍了使用垃圾收集有什么缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数现代语言都建立在垃圾回收(GC)的基础上。例如Java,.NET语言,Ruby等等。事实上,GC在许多方面简化了应用程序开发。



我很想知道在GCed语言中编写应用程序的限制/缺点。假设GC的实施是最佳的,我只是想知道我们可能会受到GC的限制来做出一些优化决定。 解决方案

主要缺点在我看来,使用垃圾收集器是:


  1. 资源的非确定性清理。有时候,说我已经完成了这个,现在我想要清理它,这很方便。使用GC,这通常意味着强制GC清理所有内容,或者等到它准备好 - 这两者都会从开发者那里拿走一些控制权。

  2. p> GC的非确定性操作引起的潜在性能问题。当GC收集时,通常会看到(小)挂起等情况,这对于实时模拟或游戏等事情来说可能是特别有问题的。



Most of the modern languages have built in garbage collection (GC). e.g. Java, .NET languages, Ruby, etc. Indeed GC simplifies application development in many ways.

I am interested to know the limitations / disadvantages of writing applications in GCed languages. Assuming GC implemenation is optimal, I am just wondering we may be limited by GC to take some optimization decisions.

解决方案

The main disadvantages to using a garbage collector, in my opinion, are:

  1. Non-deterministic cleanup of resources. Sometimes, it is handy to say "I'm done with this, and I want it cleaned NOW". With a GC, this typically means forcing the GC to cleanup everything, or just wait until it's ready - both of which take away some control from you as a developer.

  2. Potential performance issues which arise from non-deterministic operation of the GC. When the GC collects, it's common to see (small) hangs, etc. This can be particularly problematic for things such as real-time simulations or games.

这篇关于使用垃圾收集有什么缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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