[Flash] http://www.as3.kr/gc/GarbageCollectorSWF.swf
안되나?
되네...
-_-??
....!!!
-_-!!!!!
되자나!!
p.s) first 와 last 가 차이나는것은 컴퍼넌트때문에 초기화시간이 걸리는것 같다 -_-
p.s) 안되는 분은
플레이어 업데이트 해주세요.
여러분들의 검토를 부탁합니다 -_- 되는거 맞나? 그럼 초 대박인거 같은데;;
GarbageCollectorSWF.as GarbageCollectorSWF.as
package { import fl.controls.Button; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.net.LocalConnection; import flash.system.System; import flash.text.TextField; import flash.utils.Timer; public class GarbageCollectorSWF extends Sprite { // things on stage public var txtFirst: TextField; public var txtCurrent: TextField; public var txtLast: TextField; public var btnCreate: Button; public var btnClear: Button; public var canvas: Sprite; public function GarbageCollectorSWF() { var timer: Timer = new Timer( 100, 1 ); timer.addEventListener( TimerEvent.TIMER_COMPLETE, init ); timer.start(); this .btnCreate.addEventListener( MouseEvent.CLICK, create ); this .btnClear.addEventListener( MouseEvent.CLICK, clear ); } private function init( e: Event ): void { this .lastMemory = this .firstMemory = memoryKB; this .txtFirst.text = "first : " + this .firstMemory.toFixed( 2 ) + " kb" } private function create( e: MouseEvent ): void { var bmp: Bitmap; var loop: int = e.ctrlKey ? 100 : 1; while ( loop-- ) { bmp = new Bitmap( new BitmapData( 400, 300, true , 0x22FF0000 ) ); bmp.scaleX = bmp.scaleY = 0.3; bmp.x = Math.random() * 200; bmp.y = Math.random() * 100; this .canvas.addChild( bmp ); } this .update(); } private var nc: LocalConnection; private function clear( e: MouseEvent ): void { while ( this .canvas.numChildren ) this .canvas.removeChild( this .canvas.getChildAt( 0 ) ); // clear System.gc();// nc = new LocalConnection(); // nc.connect( "foo" ); // nc.close(); // try // { // nc.close(); // } // catch( e: Error ) // { // trace( "gc run~" ); // } this .lastMemory = memoryKB; this .txtLast.text = "last cleared : " + this .lastMemory.toFixed( 2 ) + " kb" this .update(); } private var currentMemory: Number = 0; private var firstMemory: Number = 0; private var lastMemory: Number = 0; private function update(): void { this .currentMemory = memoryKB; this .txtCurrent.text = "current : " + this .currentMemory.toFixed( 2 ) + " kb (" + Number( this .currentMemory - this .lastMemory ).toFixed( 2 ) + " kb increased)" ; } private function get memoryKB(): Number { return ( System.totalMemory / 10 ) / 1000; } } }
GarbageCollectorSWF.as
소스 다운로드