ljonny18
12-03-2007, 05:39 PM
Hi
I have been profiling my application in Flex 3 using the built in profiler.
I have a memory leak in my application, and from what I can tell it is coming from a tileList that I am using.
Over time the amount of instaces of a component withn (populating) my tileList increases, and thus also the memory it is using.
I am refreshing my application dataProvider every 5 seconds, and re-populating my XML dataProvider.
My tileList consists of a custom component, which is using the XML data as it dataProvider:
here is just a snippet to get the idea accross, e.g:
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
xmlns="*"
creationComplete="initApp()">
<mx:HTTPService
id="myResults"
url="http://localhost/results.xml"
resultFormat="e4x"
result="resultHandler(event)" />
<mx:Script>
<![CDATA[
private function initApp():void
{
myResults.send();
timerPulse = new Timer(5000, 0);
}
private function resultHandler(event:ResultEvent):void
{
myDataFeed = event.result as XML;
timerPulse.start();
timerPulse.addEventListener(TimerEvent.TIMER, timerRefresh);
renderTileList();
}
private function timerRefresh(eventObj:TimerEvent):void
{
timerPulse.stop();
timerPulse.removeEventListener(TimerEvent.TIMER, timerRefresh);
myResults.send();
}
private function renderTileList ():void
{
tilListHBox.removeAllChileren();
var tileListArrayCollection:ArrayCollection=new ArrayCollection();
for each(var item:XML in myDataFeed.ServerGroups.Group)
{
tileListArrayCollection.addItem({
id:item.id,
name:item.name,
status:item.status
});
}
//tileListComp = component containing mxmxl tileList
var myTileList = new tileListComp();
myTileList.dataProvider = comboTileListArrayCollection;
tilListHBox.addChild(myTileList);
}
]]>
</mx:Script>
<mx:HBox id="tilListHBox" width="100%" />
</mx:Application>
this is how my tileList ("tileListComp") looks:
<?xml version="1.0" encoding="utf-8"?>
<mx:TileList
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="*"
width="100%"
borderStyle="none"
themeColor="#99DAF2"
itemRenderer="myTileListThumb">
</mx:TileList>
and this is how the itemRenderer ("myTileListThumb") for my tileList looks:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox >
<mx:Canvas id="comboThumbCanvas">
<components:myCustomComp id="{data.id}" status="{data.status}"/>
<mx:Label id="groupName_lbl" text="{data.name}" y="72" />
</mx:Canvas>
</mx:VBox>
The item that keeps occurring (has an increasing amount of instances) is my custom component "myCustomComp" that I am populating the TileList with within the item renderer.
Every time the data ("XML") is being refreshed (every 5 seconds) the amount of instances that this component has increases - even though I am additionally clearing the tileList form the HBox every 5 seconds - tilListHBox.removeAllChileren();
could someone please tell me if I am doing something completely wrong - or help me to get rid of my leak???
I have also been told it could have something to do with the garbage collection - hcih can be affected more when refreshing large amounts of data on a regular basis - like I am doing.
Thanks again,
Jon.
I have been profiling my application in Flex 3 using the built in profiler.
I have a memory leak in my application, and from what I can tell it is coming from a tileList that I am using.
Over time the amount of instaces of a component withn (populating) my tileList increases, and thus also the memory it is using.
I am refreshing my application dataProvider every 5 seconds, and re-populating my XML dataProvider.
My tileList consists of a custom component, which is using the XML data as it dataProvider:
here is just a snippet to get the idea accross, e.g:
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
xmlns="*"
creationComplete="initApp()">
<mx:HTTPService
id="myResults"
url="http://localhost/results.xml"
resultFormat="e4x"
result="resultHandler(event)" />
<mx:Script>
<![CDATA[
private function initApp():void
{
myResults.send();
timerPulse = new Timer(5000, 0);
}
private function resultHandler(event:ResultEvent):void
{
myDataFeed = event.result as XML;
timerPulse.start();
timerPulse.addEventListener(TimerEvent.TIMER, timerRefresh);
renderTileList();
}
private function timerRefresh(eventObj:TimerEvent):void
{
timerPulse.stop();
timerPulse.removeEventListener(TimerEvent.TIMER, timerRefresh);
myResults.send();
}
private function renderTileList ():void
{
tilListHBox.removeAllChileren();
var tileListArrayCollection:ArrayCollection=new ArrayCollection();
for each(var item:XML in myDataFeed.ServerGroups.Group)
{
tileListArrayCollection.addItem({
id:item.id,
name:item.name,
status:item.status
});
}
//tileListComp = component containing mxmxl tileList
var myTileList = new tileListComp();
myTileList.dataProvider = comboTileListArrayCollection;
tilListHBox.addChild(myTileList);
}
]]>
</mx:Script>
<mx:HBox id="tilListHBox" width="100%" />
</mx:Application>
this is how my tileList ("tileListComp") looks:
<?xml version="1.0" encoding="utf-8"?>
<mx:TileList
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="*"
width="100%"
borderStyle="none"
themeColor="#99DAF2"
itemRenderer="myTileListThumb">
</mx:TileList>
and this is how the itemRenderer ("myTileListThumb") for my tileList looks:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox >
<mx:Canvas id="comboThumbCanvas">
<components:myCustomComp id="{data.id}" status="{data.status}"/>
<mx:Label id="groupName_lbl" text="{data.name}" y="72" />
</mx:Canvas>
</mx:VBox>
The item that keeps occurring (has an increasing amount of instances) is my custom component "myCustomComp" that I am populating the TileList with within the item renderer.
Every time the data ("XML") is being refreshed (every 5 seconds) the amount of instances that this component has increases - even though I am additionally clearing the tileList form the HBox every 5 seconds - tilListHBox.removeAllChileren();
could someone please tell me if I am doing something completely wrong - or help me to get rid of my leak???
I have also been told it could have something to do with the garbage collection - hcih can be affected more when refreshing large amounts of data on a regular basis - like I am doing.
Thanks again,
Jon.