Remove ArrayList Object from Memory

后端 未结 5 601
北恋
北恋 2021-01-14 13:43

I have a bunch of Objects in an ArrayList, if I call ArrayList.remove(object) Do I need to do anything else to remove the object from memory? I am

5条回答
  •  抹茶落季
    2021-01-14 13:59

    No, you don't have to do anything else, as long as that's the only place that's referencing the object. Welcome to the joys of a garbage-collected language! Java will clean up old, unreferenced objects when it decides that it needs to reclaim some memory.

提交回复
热议问题