请问这行
clip.removeChild(clip.getChildAt(0));
完全删除剪辑的孩子在0指数?我读的地方,你应该设置为空
到所有引用该剪辑,但我有我的code没有其他的参考。在0剪辑是通过定期添加的addChild()
。
completely remove the child of clip at 0 index? I read somewhere you should set to null
to all the references to that clip, but I have no other reference in my code. The clip at 0 was added via a regular addChild()
.
有关垃圾收集轻扫你的对象,你应该:
For the garbage collector to swipe your object you should:
-not have any other reference to the object throughout your code
-the object shouldn't be part of any collection (like Array or Vector)
-the current reference should be set to null
一定要格外注意第二个条件中,最常见的情况,当对象是你无法控制集合的一部分,直接是当它有一个监听器连接到它时是显示列表的一部分。最重要的是,还有其他的情况下,当对象是你可以控制一个集合的一部分,不要忘了删除它形成有太多。
Be sure to pay extra attention to the second condition, the most common situation when the object is part of a collection you can't control directly is when it had a listener attached to it and when is part of the display list. On top of that, there are other situations when the object is part of a collection you can control, don't forget to remove it form there too.
另外,迫使垃圾收集轻扫你的对象(仅用于测试,不生产),你可以使用的System.gc()
,然后检查与内存 System.privateMemory
Also, to force the garbage collector to swipe your object (only for testing, not production), you can use System.gc()
and then check the memory with System.privateMemory