share メモリにゴミが残る(正常版) nium forked:1favorite:0lines : 29license : All rights reserved modified : 2009-03-02 15:37:56 package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.net.LocalConnection; import net.hires.debug.Stats; // このクラスを実行すると、最終的に 5.9 MB 程度のメモリを消費します。 // ※消費量は実行環境によって差異があります。 public class MemoryTest extends Sprite { public function MemoryTest() { stage.addChild( new Stats() ); // 大量の MyObject インスタンスを作成する var tests:Array = []; while ( tests.length < 100000 ) { tests.push( new MyObject() ); } // stage クリックで参照を破棄する stage.addEventListener( MouseEvent.CLICK, function( e:MouseEvent ):void { tests = []; try { // 強制的に GC を発動する new LocalConnection().connect( "foo" ); new LocalConnection().connect( "foo" ); } catch ( e:Error ) {} } ); } } } class MyObject { public function MyObject() { } public function myMethod():void { } } Code Fullscreen Preview Fullscreen LocalConnection connect Error Stats MouseEvent.CLICK MouseEvent addEventListener push addChild length Array Sprite sort new page view favorite forked pv2340 メモリにゴミが残る(問題版) nium forked:4 fav:1 lines:31 tag: