从内存中删除ArrayList对象 [英] Remove ArrayList Object from Memory

查看:56
本文介绍了从内存中删除ArrayList对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我调用 ArrayList.remove(object),我在 ArrayList 中有一堆对象是否需要做其他事情才能从内存中删除对象?我正在以非常快的速度从此列表中添加和删除对象,因此,如果不从内存中删除对象,它将开始占用空间并开始降低游戏速度.

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 adding and removing objects from this list at a fairly very quick pace, so if it doesn't get removed from memory I it will start taking up space and start to slow down the Game.

推荐答案

-当调用 ArrayList.remove(object)时,您只需从列表 不是从内存中.

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

-将取决于 Garbage Collector 决定何时将其从堆中删除该对象,在正常情况下,该对象已准备好进行垃圾收集已不再引用它.

- 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.

-有一个经典的示例,说明为什么 String (它是Java中的对象)不应用于存储密码,而不是char [] 应该使用.

- 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.

查看此链接...

为什么char []优于String密码?

这篇关于从内存中删除ArrayList对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆