In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: Test_array

配列の参照を切らないと、メモリが残るテスト。
配列参照を切らなかった場合。
メモリは残り続けていきます。
/**
 * Copyright simon4761 ( http://wonderfl.net/user/simon4761 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7JJe
 */

// forked from shunsuke_ohba's forked from: Test_array
// forked from bao_bao_'s Test_array
/*
配列の参照を切らないと、メモリが残るテスト。
配列参照を切らなかった場合。
メモリは残り続けていきます。
*/
package
{
    import com.flashdynamix.utils.SWFProfiler;
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite
    {
        private var _arr:Array = [];
        public function FlashTest() 
        {
            SWFProfiler.init(this);
            (contextMenu.customItems[0] as IEventDispatcher).dispatchEvent(new ContextMenuEvent(ContextMenuEvent.MENU_ITEM_SELECT));
            addEventListener(Event.ENTER_FRAME, _onEnterFrame);
        }
        private function _onEnterFrame(e:Event):void 
        {
            var bmp:Bitmap = new Bitmap(new BitmapData(2000, 2000));
            _arr.push(bmp);
            bmp.bitmapData.dispose();
        }
    }
}