Ely, I've sent an email directly to you as well, but I thought it may be good to post it too.
Here is a "simple" demonstration of the memory leak when adding and deleting series. There are 4 components to this app: start/stop buttons, a ColumnChart, and a log window (to display the current loop counter) The script to the app has 3 important functions: SeriesDelete() and SeriesAdd() which (attempt to) delete all series from the chart, and add a series to the chart. The function onRefresh() deletes the series from the chart, gets a new data array, and adds series back onto the chart. A timer is used to put in a .5 second delay between refreshes. ActionScript member variables can be used to set the number of series, the number of data points, and the number of iterations. cheers, Thunder //----------------------------- <?xml version="1.0" encoding="iso-8859-1"?> <mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" width="100%" height="100%" > <mx:HBox> <mx:Button id="refresh" label="start" click="onRefresh()" /> <mx:Button id="cancel" label="stop" click="{refreshTimer.stop();}" /> </mx:HBox> <mx:ColumnChart id="mainChart" width="100%" height="100%"/> <mx:TextArea width="403" height="32" editable="false" id="log" wordWrap="false"/> <mx:Script> <![CDATA[ import mx.charts.*; import mx.charts.chartClasses.*; import mx.charts.series.*; import mx.collections.*; import flash.util.Timer; import flash.events.*; private var iNumReps:Number=300; private var iNumDataPoints:Number=15; private var iNumSeries:Number=50; private var iCountRep:Number=0; private var refreshTimer:Timer=new Timer(500,1); public function onRefresh(event:Event=null):void { if (event==null) { iCountRep=0; refreshTimer.addEventListener(TimerEvent.TIMER, onRefresh); } // generate a new dataset var arData:Array = getRandomData(); // delete the old series SeriesDelete(mainChart); // add new series for (var countSeries:Number=0;countSeries<iNumSeries;countSeries++) { SeriesAdd(mainChart,arData,countSeries); } // now wait for 1/2 second, and repeat iCountRep++; log.text="iteration " + iCountRep + " complete.\n"; if (iCountRep < iNumReps) { refreshTimer.reset(); refreshTimer.start(); } else { refreshTimer.stop(); } } public function SeriesDelete( thisChart:ChartBase ):void { // try to clean up the series by deleting them from the array using splice var i:Number = thisChart.series.length; while(i--) { var obj:Array = thisChart.series.splice(i, 1); var oSeries:Series = null; if (obj[0] is Series) { oSeries = Series(obj[0]); if (oSeries.dataProvider is ListCollectionView) { var oView:ListCollectionView = ListCollectionView(oSeries.dataProvider); oView.removeAll(); if (oView.list != null) oView.list.removeAll(); oView.release(); delete oView.list; oView=null; } delete oSeries.dataProvider; oSeries.dataProvider=null; delete oSeries; oSeries=null; } obj=null; } thisChart.series = new Array(); } public function SeriesAdd(thisChart:ChartBase, data:Array, seriesIndex:Number):void { var dp:ArrayCollection = new ArrayCollection(data); var sa:Array = thisChart.series var cSeries:ColumnSeries = new ColumnSeries(); cSeries.yField = "series" + seriesIndex; cSeries.name = "series" + seriesIndex; cSeries.dataProvider = dp; sa.push( cSeries ); thisChart.series = sa; // this.type = "stacked"; } public function getRandomData():Array { // generate 15 data points on 50 series (columns) var newValues:Array = new Array(); for (var countData:Number=0;countData<iNumDataPoints;countData++) { var oData:Object = new Object(); for (var countSeries:Number=0; countSeries < iNumSeries; countSeries++) { // generate a random-ish value to use oData["series"+countSeries]=Number(1+Math.random()*countSeries*100); } // add it to the array newValues.push(oData); } return newValues; } ]]> </mx:Script> </mx:Application> --- In [email protected], "Ely Greenfield" <[EMAIL PROTECTED]> wrote: > > > > Hi Thunder. It wouldn't surprise me if at this point there are leaks > when you're swapping in series. We of course want to make sure these are > all cleaned up before we ship, so If you can submit a bugfile, that > would be great. > > Ely. > > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of thunderstumpgesatwork > Sent: Tuesday, February 28, 2006 1:34 PM > To: [email protected] > Subject: [flexcoders] repost - Memory leak repeatedly assigning new > series to a chart. (2.0b1) > > Hello, > > I'm reposting this because I got no responses last time and I was hoping > one of the Flex engineers could confirm that it has been noted (if not > verified) that this is happening. > > This represents a major blocking point to releasing our app. Memory > usage CAN NOT continue to grow unbounded. > > I've narrowed it down to code which cleans up a chart's series array and > re-initializes it to add a new set of series with new dataproviders, > etc. > > Note that with only the AddSeries, and SeriesDelete functions removed > (all other code including CategoryAxis create/delete, and all XML > manipulation remained) there was no leak. > > I posted a "best practices" question about list cleanup and memory use > which describes the architecture I have: > http://groups.yahoo.com/group/flexcoders/message/29638?threaded=1 > > Below is the implementation of DeleteSeries which attempts to remove > every series in the chart and clean up the dataProvider in it. > > Can someone who knows the internal workings of the charts maybe look at > this and see if I'm missing something or if there are any known issues > with the cleanup of chart series? > > thanks, > Thunder > __________________________________ > > public static function SeriesDelete( thisChart:ChartBase ) { > // try to clean up the series > var i:Number = thisChart.series.length; > while(i--) > { > var obj:Array = thisChart.series.splice(i, 1); > var oSeries:Series = null; > if (obj[0] is Series) > { > oSeries = Series(obj[0]); > if (oSeries.dataProvider is ListCollectionView) > { > var oView:ListCollectionView = > ListCollectionView(oSeries.dataProvider); > oView.removeAll(); > if (oView.list != null) > oView.list.removeAll(); > oView.release(); > delete oView.list; > oView=null; > } > delete oSeries.dataProvider; > oSeries.dataProvider=null; > delete oSeries; > oSeries=null; > } > obj=null; > } > thisChart.series = new Array(); > } > > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

