2013-06-07

dispose 時該做些什麼

參考 Starling 論壇: question on dispose()
override public function dispose():void
{
    //dispose bitmapData
    bitmapData.dispose();
    //dispose other object witch need
    aStar.dispose();
    //set var to null, I read it was useless now, but it can t be bad..
    myObject = null;
    //remove all your listener
    removeEventListener(EnterFrame, onEnterFrame);
    //removeChild big layer to help GC to get faster
    removeChild(layer);
    //stop any timer, object, video, connection, nstream etc...
    timer.stop();
    //unregister from object if you use this
    unregisterFrom(objectListen);
    //call manually the gc if it's a big big object in memory.
    //You also can call the gc in the method witch call the object.dispose();
    System.gc();
    //call super.dispose()
    super.dispose();
}

沒有留言:

FB 留言