6

가비지 수집을 위해 클래스의 기본 유형 (uint, string, Number 등)을 null로 설정할 필요가 없다는 점을 이해합니다. 이 내가 원시 타입과 객체의 객체 사이의 차이가 무엇인지, 그것이 생각하는에 해당하는 경우ActionScript - 메모리 관리를위한 기본/비 기본 객체의 차이점은 무엇입니까?

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; 
     } 
    } 
} 

:

예를 들어, 나는 다음과 같은 클래스에서이 dispose() 방법을 쓸 필요가 없습니다입니다 메모리 할당과 관련된 비 기본 유형의

답변

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 Grant Skinner가 다른 nice set of articles on GC and resource management을 기억했습니다.

+0

GCAtomic.ppt에 대한 링크가 이미 손상되었지만 누군가가 Slideshare를 통해 해당 서비스를 제공 한 것처럼 보입니다. http://www.slideshare.net/bufanliu/gc-atomic –

1

GC는 모든 개체에서 강력한 참조가없는 개체를 제거합니다. 기본 유형 필드는 전혀 참조되지 않습니다. 해당 값은 포함 된 객체의 메모리에 직접 저장됩니다 (적어도 그렇게 생각합니다).

도움이되기를 바랍니다.

관련 문제