java中垃圾收集器的逻辑 [英] logic of Garbage collector in java

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

问题描述

我们知道垃圾收集器是java中的Thread。每个线程都有自己的逻辑来执行。所以我想知道这个垃圾收集器使用什么逻辑来维护内存。

As we know Garbage collector is Thread in java. And every thread will have its logic to execute. So i wanted to know what logic does this Garbage collector use which maintains the memory so well.

谢谢

推荐答案


当无法再从正在运行的程序中的任何指针到达对象时,该对象被视为垃圾。最直接的垃圾收集算法简单地遍历每个可到达的对象。剩下的任何对象都被认为是垃圾。这种方法所花费的时间与活动对象的数量成正比,这对于维护大量实时数据的大型应用程序来说是不可行的。

An object is considered garbage when it can no longer be reached from any pointer in the running program. The most straightforward garbage collection algorithms simply iterate over every reachable object. Any objects left over are then considered garbage. The time this approach takes is proportional to the number of live objects, which is prohibitive for large applications maintaining lots of live data.

取自 使用5.0 Java [tm]虚拟机调整垃圾收集

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

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