|
|
Home /
Groups /
Adobe Flex
AIR Clock Memory Leak
Hello again Flex list,David Henry 03/25/08 09:15 A You can submit a bug to the bug baseDouglas Knudsen 03/25/08 09:34 A Is there a way to remove the event listener each time the timerListener is fired?Gareth Arch 03/25/08 09:52 A Have you tried using the Flex profiler to help narrow it down?Jeffry Houser 03/25/08 12:38 P Yes, I thought that might work as well. I used:Bryan Clover 03/25/08 11:17 A Hello again Flex list, My team at work has a problem with a memory leak in our application which we have narrowed down to the clock. We have made a standalone version of our clock to illustrate the problem (flex3 bug maybe?). Can anyone explain why this AIR app leaks memory and how to fix it? Clock.mxml : <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();" > <mx:Script> <![CDATA[ import flash.utils.Timer; import flash.events.TimerEvent; [Bindable] private var dateAndTime:String; private var theDate:Date; private var theTimer:Timer; private function createTimer():void { theTimer = new Timer(1000, 0); var theEvent:String = TimerEvent.TIMER; var useCapture:Boolean = false; var eventPriority:uint = 0; var useWeakReference:Boolean = true; theTimer.addEventListener(theEvent, timerListener, useCapture, eventPriority, useWeakReference); theTimer.start(); } private function init():void { createTimer(); } private function timerListener(event:TimerEvent):void { theDate = new Date(); dateAndTime = theDate.toLocaleString(); //leak seems to happen here. } ]]> </mx:Script> <mx:Label id="dateAndTimeLBL" text="{dateAndTime}" right="10" top="122" color="#000000" fontSize="28" textAlign="center" width="501" /> </mx:WindowedApplication> Thanks for your input! David -- [Image:Our Hero] David Henry http://ColdFusionPowered.com/ You can submit a bug to the bug base http://bugs.adobe.com/flex/ DK On Tue, Mar 25, 2008 at 9:15 AM, David Henry < DavidHenry@coldfusionpowered.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- Is there a way to remove the event listener each time the timerListener is fired? private function timerListener(event:TimerEvent):void { theTimer.removeEventListener(TimerEvent.TIMER, timerListener, false, 0, true); theDate = new Date(); dateAndTime = theDate.toLocaleString(); //leak seems to happen here. } but still keep the timer firing and listening for the events? ----- Excess quoted text cut - see Original Post for more ----- Have you tried using the Flex profiler to help narrow it down? David Henry wrote: ----- Excess quoted text cut - see Original Post for more ----- -- Jeffry Houser Flex, ColdFusion, AIR AIM: Reboog711 | Phone: 1-203-379-0773 -- Adobe Community Expert <http://www.adobe.com/communities/experts/members/JeffryHouser.html> My Company: <http://www.dot-com-it.com> My Podcast: <http://www.theflexshow.com> My Blog: <http://www.jeffryhouser.com> Yes, I thought that might work as well. I used: theTimer.removeEventListener(TimerEvent.TIMER, timerListener); But, according to the Flex 3 profiler...the timer still eats up 1kb per second. Thanks!
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||