Java垃圾收集 [英] Java Garbage Collection

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

问题描述

我想知道在Java中发生的垃圾回收。是真的能够处理所有没有使用的对象,释放最可能的内存吗?

I was wondering about the garbage collection that takes place in Java. Is it really able to handle all objects that aren't used and free up the most possible memory?

我也想知道Java垃圾回收如何与另一个语言喜欢让我们说C#?那么,自动垃圾回收如何与C?之类的语言进行手动收集呢?

I also want to know how does the Java garbage collection compare to another language like lets say C#? And then, how does the automatic garbage collection measure up against manual collection from a language like C?

推荐答案

的垃圾收集。

有许多不同形式的垃圾收集。最简单的形式,引用计数,不能处理某种类型的垃圾(循环引用),而不增强算法。

There are many different forms of garbage collection. The simplest form, reference counting, is not able to handle certain type of garbage (circular references) without enhancements to the algorithm.

Java(Sun JVM)使用代标记和扫描收集器,虽然这不是标准化,不同的JVM确实使用不同的收集器。我不知道.NET CLR使用的确切收集器。

Java (the Sun JVM) uses a generational mark and sweep collector, though this is not standardized and different JVMs do use different collectors. I do not know the exact collector used by the .NET CLR.

垃圾收集器像减少程序员开销,并且可以使某些算法表现更好。但是,它们的内存占用量通常大于紧密的手动分配系统。

Garbage collectors like reduce programmer overhead, and can make certain algorithms perform better. However, their memory footprint is generally larger than a tight manual allocation system.

此主题的defacto参考是 book Garbage Collection ,这是写得很好,全面的。

The defacto reference on this topic is the book Garbage Collection, which is well written and comprehensive.

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

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