I think your test "outruns" the garbage collector.  50ms is a pretty
short interval and the GC is incremental, it tries not to affect other
code so it won't always collect everything, then 50ms later you create a
whole pile of things.  I think another factor is that the 10th ComboBox
might cause scrollbars to appear which generates a whole other pile to
keep up with, but I didn't confirm that.  For me, I can reproduce your
results at 50ms, but if I slow the interval to 200ms, I had it run for 3
hours without significant creep.
 
Bugs can be filed at www.adobe.com/go/wish, but this one will likely be
relegated to the "fact-of-life" bin.  One would recommend optimizing the
code (hiding the dialog instead of creating/destroying it each time) or
other tricks like that.
 
-Alex

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of geoffreymina
Sent: Saturday, April 14, 2007 7:24 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] PopUpManager Memory Leak > 10 children???



I am not sure how Adobe goes about logging bug reports, but I have
tracked down a serious memory leak in the PopUpManager class. I have
worked up a little two file application which will demonstrate the
problem. The first file contains a Timer object which fires every 50
milliseconds. Each time it fires it executes the createPopUp() and
removePopUp() methods of the PopUpManager. The values of
System.totalMemory are neatly displayed at the bottom so you can see
when the leak occurs and when it doesn't.

The createPopUp() method uses the LeakTest.mxml class which is simply a
<TitleWindow> with 10 <ComboBox> elements inside. When you run the test
you will see that the memory just keeps going up and up and up and up
until finally the browser will crash.

Here is the VERY interesting thing... If you comment out a single
<ComboBox> from the LeakTest.mxml file you will see tha the memory leak!
no longer occurs.   To restate, with 9 combobox objects the memory leak
does NOT occur... but with 10 it does??? WTF??? Apparently 10 is just
one too many? Does anyone have any idea what is up with this, or how to
go about notifying adobe about the issue?

 

Thanks,

Geofff 

***********************************************************
***************** FILE: MemoryLeakTest.mxml ***************
***********************************************************

<?xml version="1.0"?>
<mx:Application 
 xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " 
 xmlns:local="*" 
 creationComplete="createComplete()">
 
 
 <mx:Script>
  <![CDATA[
   import mx.formatters.NumberFormatter;
   import mx.core.IFlexDisplayObject;
   import mx.managers.PopUpManager;
  
   [Bindable]
   public var initialMemory:Number = System.totalMemory;
   
   [Bindable]
   public var currentMemory:Number = System.totalMemory;
     
   [Bindable]
   public var maxMemory:Number = System.totalMemory;
      
   [Bindable]
!    public var windowsOpened:Number = 0;
    
    
   public var timer:Timer = new Timer(50);
   
   [Bindable]
   public var format:NumberFormatter = new NumberFormatter();
        
   public function createComplete():void{
    timer.addEventListener("timer",startTest);
    format.precision = 0;
   }
  
   public function startTest(event:TimerEvent):void{
    windowsOpened++;
    currentMemory = System.totalMemory;
    if(currentMemory > maxMemory){maxMemory = currentMemory;}

    var window:IFlexDisplayObject =
PopUpManager.createPopUp(this,LeakTest,false); 
    PopUpManager.removePopUp(window);
   }
   
  ]]>
 </mx:Script>
        
 <mx:VBox>
  <mx:Button label="Start Test" click="timer.start();"/>
  <mx:Button label="Stop Test" click="timer.stop();"/>
  <mx:Label text="Current Memory Usage: {this.currentMemory/1024}"/>
  <mx:Label text="Maximum Memory Usage: {this.maxMemory/1024}"/>
  <mx:Label text="Departure from Initial Consumption:
{this.format.format((this.initialMemory/(this.currentMemory-this.initial
Memory))*100)}%"/>
  <mx:Label text="Windows Opened: {this.windowsOpened}"/&! gt;
 </mx:VBox>           
</mx:Application>

 

 

***********************************************************
***************** FILE: LeakTest.mxml *****************
***********************************************************


<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml";
<http://www.adobe.com/2006/mxml>  width="400" height="300">
<mx:VBox> 
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"! />
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<! ;mx:ComboBox>
<mx:Array>
<mx:Object label="1! " data=" 1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
<mx:ComboBox>
<mx:Array>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
<mx:Object label="1" data="1"/>
</mx:Array> 
</mx:ComboBox>
</mx:VBox>
</mx:TitleWindow> 



 

Reply via email to