相変わらずメモリ馬鹿食いのFlex2ですが、実行中のアプリがどのぐらいメモリを使っているかというのは
「flash.system.System.totalMemory」という関数で調べることが出来ます。
この関数を利用して、1秒ごとに使用メモリを表示するコンポーネントを作ると、こんな感じです。
<?xml version="1.0" encoding="utf-8"?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="160" height="24" creationComplete="init()" backgroundColor="#000000"> <mx:Script> <![CDATA[ import flash.system.fscommand; import flash.utils.Timer; import flash.events.TimerEvent; public function init():void { var timer:Timer = new Timer(1000, 0); timer.addEventListener("timer", timerHandler); timer.start(); } public function timerHandler(event:TimerEvent):void { ta1.text = "use memory:" + int((flash.system.System.totalMemory/1024)) + " kbyte"; } ]]></mx:Script> <mx:Label id="ta1" height="24" color="#FFFFFF"/> </mx:HBox>
「MemoryCounter.mxml」みたいなファイルを作って保存すると完成です。
このコンポーネントを画面に張ると、使用メモリがキロバイト単位で表示されます。
ただしWindowsのタスクマネージャーで出る数値とかけ離れていますが・・・・
メモリが増えていく様子を見る分には最適です。