Remove ArrayList Object from Memory

后端 未结 5 651
北恋
北恋 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:20

    - When you call ArrayList.remove(object), you just remove the objects from the List Not from the Memory.

    - It will depend on the Garbage Collector to decide when its gonna remove the object from the heap, under normal circumstances its an object is ready for garbage collection as it has No reference to it anymore.

    - There is a classic example of why String which is an object in Java should not be used for storing password instead char[] should be used.

    See this link...

    Why is char[] preferred over String for passwords?

提交回复
热议问题