Forked from: nium's メモリにゴミが残る(正常版) diff(4) share メモリにゴミが残る(問題版) nium forked:4favorite:1lines : 31license : All rights reserved modified : 2009-03-02 15:40:54 package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.net.LocalConnection; import net.hires.debug.Stats; // このクラスを実行すると、最終的に 8.3 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() { // クラスメソッドをローカル変数に代入して破棄する var value:Function = myMethod; value = null; } public function myMethod():void { } } Code Fullscreen Preview Fullscreen dealforest LocalConnection connect Error Stats MouseEvent.CLICK MouseEvent addEventListener push addChild length Array Sprite sort new page view favorite forked pv115 forked from: メモリにゴミが残る(問題版) mtok forked:0 fav:0 lines:29 tag: pv267 forked from: メモリにゴミが残る(問題版) sph62 forked:0 fav:1 lines:30 tag: pv388 forked from: メモリにゴミが残る(問題版) taiga forked:0 fav:1 lines:34 tag: Dictionary LocalConnection connect pv459 forked from: メモリにゴミが残る(問題版) muraken forked:0 fav:0 lines:33 tag: