Does it help GC to null local variables in Java

前端 未结 15 2005
旧巷少年郎
旧巷少年郎 2020-12-02 13:06

I was \'forced\' to add myLocalVar = null; statement into finally clause just before leaving method. Reason is to help GC. I was told I will get SMS\'s during n

15条回答
  •  独厮守ぢ
    2020-12-02 14:00

    That is a myth that goes way back to when java first came out and C++ guys didn't trust the gc.

    The gc knows what it is doing. nulling out var wont hurt anything, but it wont really help anything either. Jeff had a pretty funny post on this just the other day.

提交回复
热议问题