我很想知道, j瓦的垃圾收集器是否能够收集分配给树木的所有记忆,如果仅仅把树木的根基点定为无效,而没有规定每个单点的“无效”,因为在根子被确定为无效之后,不会活着地提及 no?
Yes. When the last live external reference to a network of nodes is removed, all of the nodes are eligible for garbage collection. This sounds like what you are describing.
如果能够收集树木的记忆,它会使用多块垃圾收集器穿过每层树木?
简而言之,停车场收集器可将其全部删除。 在任何使用标识的垃圾收集器(而不是参考值)中,垃圾收集器不必绕过停车场的物体网络。 相反,它渗透和标志NON-garbage物体,并将它标记的物体作为垃圾处理。
In practice, sophisticated garbage collectors partition the heap into spaces (e.g. a new generation and one or more old generations) and can garbage collect (at least) some of them independently. If your tree s nodes have been migrated to an older generation space, then it could take more than one "cycle" of the GC to delete them all. However, there s not much you can do about this ... and you shouldn t care about it anyway.