Destroying objects in Java

后端 未结 8 765
走了就别回头了
走了就别回头了 2021-01-22 00:07

I have a general idea of how the Garbage Collector works in Java, but my reasoning for destroying an object is not because I care about freeing up memory, but because of functio

8条回答
  •  臣服心动
    2021-01-22 00:46

    You simply have to avoid making 'dollar' available to places you don't want it to go. Note that this isn't really a GC issue. For a non-GC environment (like C++) someone who somehow sees a pointer to an deleted object will crash and burn if they try accessing it.

提交回复
热议问题