Objectはいくつまで格納できるか

by uwi
stopを押さないと際限なくメモリ使用量が増えていきます。
♥0 | Line 43 | Modified 2009-11-25 12:40:48 | MIT License
play

ActionScript3 source code

/**
 * Copyright uwi ( http://wonderfl.net/user/uwi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1OBG
 */

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.utils.getTimer;
    import flash.events.*;
    import flash.system.*;
    import com.bit101.components.*;

    // stopを押さないと際限なくメモリ使用量が増えていきます。
    public class Euler extends Sprite {
        private var _tf : TextField;
  
        public function Euler() {
            _tf = new TextField();
            _tf.width = 465;
            _tf.height = 465;
            addChild(_tf);
            
            var pb : PushButton = new PushButton(this, 350, 10, "stop", function(e : Event) : void
                {
                    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
                });
            pb.width = 100;
                    
            _o = {};
            _t = 0;
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private var _o : Object;
        private var _t : int;

        private function onEnterFrame(e : Event) : void
        {
            var N : int = 100000;
            for(var i : int = _t;i < _t + N;i++){
                _o[i] = i;
            }
            _t += N;
            _tf.text = "";
            tr(_t);
            tr("memory : " + System.totalMemory);
        }

        private function tr(...o : Array) : void
        {
            _tf.appendText(o + "\n");
            _tf.scrollV = _tf.maxScrollV;
        }
    }
}

Forked