Hi, I've been having memory problems with my application when it's left running overnight in IE7, which often results in IE crashing and a flash9.ocx error popup.
Anyway, I'm struggling to pin down where the problem is coming from. I know about the seemingly whimsical nature of when garbage collection is done, but even still this behaviour seems strange to me: (See the sample project below) With just a VideoDisplay object playing video (or paused!) the memory will keep going up for a couple of Mb at least. At some stage the garbage collection will kick in and it will recycle, but is this normal/expected behaviour. It looks funny for my application, which is very video reliant, to have the memory constantly fluctuating even when the user is doing nothing. It also makes debugging for my memory leak very tricky. Does anyone have any advice for tracking down my problem? Would it be making a difference that I have the debug version of flash? Here's the sample app (not very neat) that demonstrates the problem. Just click "Load" followed by "Play/Pause" and watch the memory go. Sometimes if I click about on the slider or pause and play or even just leave it for a while the problem becomes more pronounced. (Also using the add/remove buttons to add extra components doesn't seem to cause the garbage collection to occur) <?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalScrollPolicy="off" layout="absolute" creationComplete="initTimer()" bottom="0" height="648"> <mx:Script><![CDATA[ import flash.utils.Timer; import flash.events.TimerEvent; [Bindable] public var time:Number = 0; [Bindable] public var totmem:Number = 0; [Bindable] public var maxmem:Number = 0; [Bindable] public var initmem:Number = 0; private var mCount:int = 0; public function initTimer():void { // The first parameter is the interval (in milliseconds). The // second parameter is number of times to run (0 means infinity). var myTimer:Timer = new Timer(1000, 0); myTimer.addEventListener("timer", timerHandler); myTimer.start(); initmem = flash.system.System.totalMemory; } public function timerHandler(event:TimerEvent):void { time = getTimer() totmem = flash.system.System.totalMemory; maxmem = Math.max(maxmem, totmem); } private function add():void { var theLabel:Label = new Label(); theLabel.condenseWhite=false; theLabel.text= "testing"; theLabel.name = "id"+ mCount; mCount++; theLabel.truncateToFit=true; this.box.addChild(theLabel); } private function remove():void { mCount--; var theLab:Label = Label(this.box.getChildByName("id" + mCount)) this.box.removeChild(theLab) } private function gc():void { try { var lc1:LocalConnection = new LocalConnection(); var lc2:LocalConnection = new LocalConnection(); lc1.connect('name'); lc2.connect('name'); } catch (e:Error) {} } private function slider_change():void { vid.playheadTime = slider.value } private function loadVid():void { vid.source='http://www.youtube.com/get_video.php? video_id=GTXinF8ZVCo&t=OEgsToPDskJ4R8PZpQMwNWLj_IyZOhvr' } private function playPause():void { vid.volume=0; if (vid.playing != true) vid.play(); else vid.pause(); } ]]></mx:Script> <mx:Form id="frm"> <mx:FormItem label="Time:"> <mx:Label text="{time} ms"/> </mx:FormItem> <mx:FormItem label="Total Memory:"> <mx:Label text="{totmem} bytes"/> </mx:FormItem> <mx:FormItem label="Max Memory:"> <mx:Label text="{maxmem} bytes"/> </mx:FormItem> <mx:FormItem label="Init Memory:"> <mx:Label text="{initmem} bytes"/> </mx:FormItem> <mx:Button label="Do garbage collection" click="gc()" /> </mx:Form> <mx:VBox top="10" bottom="219" borderThickness="3" verticalScrollPolicy="auto" horizontalScrollPolicy="off" x="245"> <mx:VideoDisplay id="vid" autoPlay="false" width="480" height="359"/> <mx:HSlider id="slider" minimum="0" maximum="{vid.totalTime}" value="{vid.playheadTime}" change="slider_change()" width="478"/> <mx:HBox> <mx:Button label="Load" click="loadVid()" /> <mx:Button label="Play/Pause" click="playPause()" /> </mx:HBox> </mx:VBox> <mx:VBox id="box" width="200" height="200" x="10" y="158"> <mx:HBox> <mx:Button label="add" click="add()"/> <mx:Button label="remove" click="remove()"/> </mx:HBox> </mx:VBox> </mx:Application> Thanks in advance! Bill

