R***Z 发帖数: 1167 | 1 In Java, suppose obj A has a reference to obj B, obj B has a reference to obj
C, and obj C has a reference to obj A. And no one else has any reference to
these 3 objs. So each of them has a reference count of 1. But they should
really be GCed because they are not reachable by any means. How does the
garbage collector know these 3 objs can be GCed? Thanks. | m******t 发帖数: 2416 | 2
obj
JVM does not use reference counting-based GC. These object would be GC'ed
without any problem.
【在 R***Z 的大作中提到】 : In Java, suppose obj A has a reference to obj B, obj B has a reference to obj : C, and obj C has a reference to obj A. And no one else has any reference to : these 3 objs. So each of them has a reference count of 1. But they should : really be GCed because they are not reachable by any means. How does the : garbage collector know these 3 objs can be GCed? Thanks.
| g*****g 发帖数: 34805 | 3 http://www.brpreiss.com/books/opus5/html/page424.html
Algorithm like mark and sweep, does the job.
Note Java standard didn't specify how JVM should implement
its recycle scheme.
【在 m******t 的大作中提到】 : : obj : JVM does not use reference counting-based GC. These object would be GC'ed : without any problem.
|
|