Assigning “null” to objects in every application after their use

前端 未结 14 782
感动是毒
感动是毒 2021-01-18 12:05
  • Do you always assign null to an object after its scope has been reached?

  • Or do you rely on the JVM for garbage collection?

14条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 12:44

    • no, don't do that, except for specific cases such as static fields or when you know a variable/field lives a lot longer than the code referencing it
    • yes, but with a working knowledge of your VM's limits (and how to cause blocks of memory to be held accidentally)
    • n/a

提交回复
热议问题