6

ガベージコレクションのために、クラスのプリミティブ型(uint、string、Numberなど)をnullに設定する必要はありません。ActionScript - メモリ管理のプリミティブオブジェクトと非プリミティブオブジェクトの違い

例えば、私は次のクラスでは、この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; 
     } 
    } 
} 

、私はそれがあると信じている、プリミティブ型のオブジェクトとオブジェクトの違いは何ですかメモリ割り当てに関する非プリミティブ型の

答えて

6

私が知る限り、フラッシュプレーヤーVMのGCロジックの最も完全で詳細な説明はin the blog of Alex Harui, written back in 2007です。直接リンク:GCAtomic.ppt。参照と参照カウントと

And here are some useful hints on GC from Grant Skinner.

GCロジックを扱っています。 ActionScriptではプリミティブへの参照を取得できないため、この点ではGCについては何もできません。

EDITグラントスキナーの別のnice set of articles on GC and resource managementがちょうど覚えています。

+0

GCAtomic.pptへのリンクは既に破損していますが、誰かがSlideshare経由で利用できるように見えます。http://www.slideshare.net/bufanliu/gc-atomic –

1

GCは、どのオブジェクトでも強参照されていないオブジェクトを削除します。プリミティブ型のフィールドはまったく参照されません。その値は、格納されているオブジェクトのメモリに直接格納されます(少なくとも私はそうだと思います)。

私はそれが役に立ちそうです。

関連する問題