When Is The Object Eligible For Garbage Collection?

后端 未结 7 621
后悔当初
后悔当初 2020-11-27 07:22

In the code below, given that amethod has been called. At what point/line is the Object originally referenced by myObject, eligible for Garbage Col

相关标签:
7条回答
  • 2020-11-27 08:23

    In the code below, given that amethod has been called. At what point/line is the Object originally referenced by myObject, eligible for Garbage Collection?

    Your question is nonsensical because there is a disconnect between your high-level source code and the low-level representation (global roots in registers, on the stack and in global variables) that the garbage collector sees.

    Your phrase "eligible for garbage collection" presumably means at what point does a heap-allocated block of memory become unreachable. So your question can only be answered by making a lot of (dubious) assumptions about what heap allocates and how long the generated code will keep references.

    0 讨论(0)
提交回复
热议问题