The*_*978 6 garbage-collection memory-management actionscript-3 primitive-types
我的理解是,对于垃圾收集,类的原始类型(uint,string,Number等)不需要设置为null.
例如,我不需要dispose()在以下类中编写此方法:
package
{
//Imports
import flash.display.Shape;
//Class
public class DrawSquare extends Shape
{
//Properties
private var squareColorProperty:uint;
//Constructor
public function DrawSquare(squareColor:uint)
{
squareColorProperty = squareColor;
init();
}
//Initialize
private function init():void
{
graphics.beginFill(shapeColorProperty);
graphics.drawRect(0, 0, 200, 200);
graphics.endFill();
}
//Dispose
public function dispose():void
{
squareColorProperty = null;
}
//Get Shape Color
public function get squareColor():uint;
{
return squareColorProperty;
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果这是真的,我相信它是什么,原始类型的对象和非原始类型的对象有关内存分配的区别是什么?
据我所知,Flash播放器VM中GC逻辑的最完整和详细的解释位于Alex Harui的博客中,该博客于2007年写成.直接链接:GCAtomic.ppt.
GC逻辑处理引用和引用计数.由于您无法在ActionScript中获取对基元的引用,因此您无法在此方面对GC执行任何操作.
编辑刚刚记得Grant Skinner 关于GC和资源管理的另一篇很好的文章.