Remove ArrayList Object from Memory

后端 未结 5 602
北恋
北恋 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 14:22

    Java does automatic garbage collection. So once an object is no longer referred to, it can be deleted, that doesn't mean it will be deleted. Garbage collection is automatic, you can ask that it be done by calling System.gc() however this is just a sugestion to run it.

    http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html#gc%28%29

提交回复
热议问题