What triggers the java Garbage Collector

前端 未结 3 1437
不知归路
不知归路 2021-01-28 05:20

I am a little confused to how garbage collection in Java works.

I get that an object becomes eligible for garbage collection when there are no more live references to it

3条回答
  •  隐瞒了意图╮
    2021-01-28 05:59

    The GC knows which objects are alive because it copies all live objects to a new memory area and all that are not copied are overwritten the next time.

    Note that this is valid for current implementations of the GC in the Oracle VM. Other VMs could handle it another way.

提交回复
热议问题