How does Garbage Collection in Java work?

后端 未结 9 2158
生来不讨喜
生来不讨喜 2021-02-08 04:36

I was wondering how the garbage collector in Java deals with the following situation.

Object A has a reference to Object B and Object B has a reference to Object C. The

9条回答
  •  一整个雨季
    2021-02-08 05:23

    B and C are eligable for garbage collection because you can't access them any more. With the unpredicatbility of the garbage collector all we know is they are quite likely to get collected at some point in the future.

提交回复
热议问题