AS3:标记为垃圾收集的变量,空或删除吗?或删除、变量、标记、垃圾

2023-09-08 13:35:41 作者:自饮毒酒

如果你有一个变量,它是一个影片剪辑,雪碧,字符串,数字,INT,UINT,或者逻辑,你删除它的参考加入:

  myVariable的= NULL;
 

 删除(myVariable的);
 
AS3基础教程 第2课 变量与trace函数

解决方案

将其设置为null是足以去除引用它包含的对象。

注意的语法删除运算符是删除object.member ,其中删除成员从一个键对象,因此将删除的引用,不管它包含的内容。

注意,GC只能出现一次的所有的引用给定对象都被删除。

If you have a variable that is a MovieClip, Sprite, String, Number, int, uint, or a Boolean, do you remove it's reference by adding:

myVariable = null;

OR

delete(myVariable);

解决方案

setting it to null is sufficient to remove a reference to the object it contained.

Note that the syntax of the delete operator is delete object.member, which removes member as a key from object, and as such will remove a reference to whatever it contains.

note that GC can only occur once all references to a given object are removed.