我的理解是,类的基本类型(如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;
}
}
}
如果这是真的,我相信是这样的,原始类型的对象和非原始类型的对象在内存分配方面有什么区别?