Make sure your scenario should be using loitering objects.  As I explain in the 
blog article, many scenarios will get false results using loitering objects.

If you look at the allocation traces for the objects in question, you can then 
consider how those created objects get released so they can be garbage 
collected.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Dharmendra Chauhan
Sent: Saturday, June 27, 2009 12:25 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Memory Leak in DataServices based App ??





I have gone throw your tutorial on you blog  and I profiled my with. I could 
see so many loitering object hanging around  , I evaluted them based upon the 
method suggetsed on your blog.
Potential  Loitering Obejct which I could see is -

 *   Objects
 *   Strings
On drill down , I found tons of obejct of following :-
      AbstradeDataServies
      NetConnetions
       ManagedObjectPeoxy- It is refering to DataGridItemRenderer

 Worst part is they keep increasing everytime when I load the  data and remove 
it.

I have removed all my custom code and now app is very bare bone.Lately I though 
I could seek help from flexCoders.

- Dharmendra














!










--- In flexcoders@yahoogroups.com, Alex Harui <aha...@...> wrote:
>
> What does the memory profiler say? There's a "tutorial" on how to use it on 
> my blog.
>
> Alex Harui
> Flex SDK Developer
> Adobe Systems Inc.<http://www.adobe.com/>
> Blog: http://blogs.adobe.com/aharui
>
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On 
> Behalf Of Dharmendra Chauhan
> Sent: Friday, June 26, 2009 10:21 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Memory Leak in DataServices based App ??
>
>
>
>
>
> Hi All,
>
> I have very basic application which uses DataSerives over RTMP channel to 
> populate dataGrid , I have not used any user defined component.
>
> This application has got LOAD data and Remove data Button j! ust to simulate 
> the actual application
>
> What h! appens , when I click on LOAD data , It loads the data from 
> server(JBOSS) then I Remove all the data and force the GC to run
>
> If I continuously keep loading and removing the data , memory goes up every 
> time and after some times It reaches to threshold and finally crashes the 
> Browser.
>
> In actual application as soon as user logs in a dedicated DS destination is 
> created..
>
> private function createDestination(destName:String):void{
> var remoteServi! ce:RemoteObject = new RemoteObject("DestinationManager");
> remoteService.addEventListener(ResultEvent.RESULT, 
> resultHandler,false,0,true);
> var operation:AbstractOperation = 
> remoteService.getOperation("createDestination");
> operation.send(destName);
> var cs:ChannelSet = new ChannelSet();
> var rtm! pChannel:RTMPChannel = ServerConfig.getChannel("my-rtmp") as 
> RTMPChannel;
> cs.addChannel(rtmpChannel);
> ! ; tradeService = new DataService() ;
> ! ; & nbsp; tradeService.destination=destName;
> tradeService.channelSet = cs;
> }
>
>
> Now when user hits on Load data button to load the trade data ...
>
> public function loadData():void
> {
> var remoteService:RemoteObject = new RemoteObject("filterRemoteVO");
> var operation:AbstractOperation = remoteService.getOperation("loadData");
> tradeService.fill(tradeCollection);
> operation.send(rowData.t! ext ,GUIID);
> tradeList.dataProvider = tradeCollection;
>
> }
>
>
> Remove Dat! a hit I clean all the resource and released collection :-
! >
> public function removeAll():void{
> if(tradeList.dataProvider){
> tradeCollection.source = new Array();
> tradeList.dataProvider.source = new Array();
> tradeList.dataProvider = null;
> }
> tradeService.release();
> &nb! sp; ; tradeService.releaseCollection(tradeCollection);
> tradeService.channelSet.disconnectAll();
> tradeService.disconnect();
> tradeService.logout();
> System.gc();
> }
>
> Except these 3 function I don't have any code which could cause memory leak.
>
> I m using
>
> * LCDS 2.5
> * Flex 3.0
> * JBoss4.2
>
> Please see the mxml file below , If possible please have a look at it , I 
> might not be! using dataSerice API correctly.
>
> I have been trying to solve this leak for last two week , I really need help 
> from you guys.
> My client has already evaluating other contemporary technology because of 
> this memory issue.
>
> I have al! so created scalled down war file which can be deployed on any java 
> application server.Just provide your emial Id , Iwill send that to you.
>
> Any help will greatly be appreciated
>
> Regards,
>
> Dam
> ######################## MXML##########################
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
> creationComplete="init();" height="100%" width="100%"
> >
> <mx:Script >
> <![CDATA[
> import mx.containers.GridRow;
> ! import mx.utils.Base64Decoder;
> impor! t mx.uti ls.StringUtil;
> import mx.events.Colle! ctionEvent;
> ! import mx.formatters.Formatter;
> import mx.events.ResizeEvent;
> import mx.controls.DataGrid;
> import mx.effects.Fade;
> import mx.events.DataGridEvent;
> import mx.utils.ObjectUtil;
> import mx.events.ScrollEvent;
> import mx.formatters.DateFormatter;
> import mx.events.ListEvent;
> import mx.data.mxml.DataService;
> import mx.messaging.config.ServerConfig;
> import mx.messaging.channels.RTMPChannel;
> import mx.messaging.ChannelSet;
> &n! bsp; import mx.rpc.AbstractOperation;
> import mx.rpc.remoting.RemoteObject;
> import mx.collections.ArrayCollection;
> import mx.controls.Alert;
> ! import mx.rpc.events.ResultEvent;
> import mx.messaging.messages.*;
> import mx.messaging.events.*;
> import mx.controls.Alert;
>
>
>
> private var GUIID:String;
> private var lastRollOverIndex:Number;
>
> public var tradeService:DataService=null;
> public var tradeCollection:ArrayCollection = new ArrayCollection();
>
> ! public var flag:Boolean = false;
> &! nbsp;&nb sp;
>
> private function init():void {
> var guiId:String ="TEST";
> createDestination(GUIID);
>
> }
>
> public function getData():void{
>
> // memory.text =""+ ((System.totalMemory / 1024)/1024);
>
> }
> public function releaseDataServices():v! oid {
> // tradeService.fill(nul! l);> tradeService.release();
> // tradeService.releaseCollection(tradeCollection);
> tradeService.channelSet.disconnectAll();
> tradeService.disconnect();
> tradeService.logout();
> //tradeService.dataStore = null;
> }
> /*Function for creating destination*/
> &nb! sp; private function createDestination(! destName :String):void{
> var remoteService:RemoteObject = new RemoteObject("DestinationManager");
> remoteService.addEventListener(ResultEvent.RESULT, 
> resultHandler,false,0,true);
> var operation:AbstractOperation = 
> remoteService.getOperation("createDestination");
> operation.send(destName);
> ! var cs:ChannelSet = new ChannelSet();
> var rtmpChannel:RTMPChannel = ServerConfig.getChannel("my-rtmp") as 
> RTMPChannel;
> cs! .addChannel(rtmpChannel);
> tradeService = new DataService() ;
> tradeService.destination=destName;
> tradeService.channelSet = cs;
> }
>
> //This function calls dataservice fill method depending on wheather 
> destination is created or not
> private function resultHandler(event:ResultEvent):void{
> //call data service as destination is created successfully
> var status:Boolean = event.result as Boolean
> ! ; // Alert.show("status="+status); if(status){
>
> getData();
> }
> else{
> //TODO report erro! r to MATS app
> }
> }
> ! public function removeAll():void{
> if(tradeList.dataProvider){
> tradeCollection.source = new Array();
> tradeList.dataProvider.s! ource = new Array();
> tradeList.dataProvider = null;
> }
> tradeService.release();
> // tradeService.releaseCollection(tradeCollection);
> tradeService.channelSet.disconnectAll();
> tradeService.disconnect();
> tradeService.logout();
> System.gc();
> }
>
>
> public function loadData():void
> &nb! sp; { &nb! sp; ;
> var remoteService:RemoteObject = new RemoteObject("filterRemoteVO");
> var operation:AbstractOperation = remoteService.getOperation("loadData");
! > tradeService.fill(tradeCollection);
> operation.send(rowData.text ,GUIID);
> tradeList.dataProvider = tradeCollection;
>
> }
>
> ]]>
> </mx:Script>
>
>
> <mx:DataGrid id="tradeList"
> initialize="tradeList.dataProvider = tradeCollection" 
> horizontalScrollPolicy="auto"
> &nbs! p; height="659" x="0" y="84">
>
> <mx:columns>
> <mx:DataGridColumn headerText="Security Description" dataField="securityDesc"
> />
> <mx:DataGridColumn headerText="B/S" dataField="transactionType"
> />
> <mx:DataGridColumn headerText="Amount" dataField="amount"
> &nbs! p; />
> &n! bsp;&a! mp;nbs p; <mx:DataGridColumn headerText="P! rice Tex t" 
> dataField="priceText"
> />
> <mx:DataGridColumn headerText="Counterparty" dataField="counterParty"
> />
> <mx:DataGridColumn headerText="Trade Date" dataField="tradeDate"
> />
> <mx:DataGridColumn headerText="Settle Date" dataField="settleDate"
> />
> <mx:DataGridColumn headerText="Trade Status" dataField="tradeStatusId"
> />
> <mx:DataGridColumn headerText="Trader" dataField="trader"
> />
> <mx:DataGridColumn headerText="Salesperson" dataField="salesperson"
> />
> &! nbsp; <mx:DataGridColum! n headerText="Ticket Number" 
> dataField="tradeNumber"
>! ; />
> <mx:DataGridColumn headerText="Entry Date" dataField="tradeTime"
> />
> <mx:DataGridColumn headerText="Cancel Date" dataField="cancelDate"
> />
> <mx:DataGridColumn headerText="Cancel Time" dataField="cancelTime"
> &nb! sp; />
>
>
>
> </mx:columns>
> </mx:DataGrid >
> <mx:Grid x="149" y="23" width="995">
> <mx:GridRow width="100%" height="100%">
> <mx:GridItem width="100%" height="100%">
> <mx:Label text="Enter No of obejcts" width="111"/>
> &nbs! p; </mx:Gri! dItem> ;
> <mx:GridItem width="1! 00%" height="100%">
> ! &l t;mx:TextInput name="row" id="rowData" width="97"/>
> </mx:GridItem>
> <mx:GridItem width="100%" height="100%">
> ! <mx:Button label="Load Data" click='loadData()'/>
> </mx:GridItem>
> <mx:GridItem width="100%" height="100%">
> <mx:Button label="removeAll" click='removeAll()'/>
> </mx:GridItem>
> &! nbsp; <mx:GridItem width="100%" height="100%">! ;
> &nb sp; <mx:Label text="Total Memory"/>
> </mx:GridItem>
> <mx:GridItem width="100%" height="100%">
> <mx:TextInput text="Total Memory! " id="memory" width="97"/>
> &! lt;/mx:GridItem>
> <mx:GridItem width="100%" height="100%">
> <mx:Label text="Grid Row Count"/>
> </mx:GridItem>
> <mx:GridItem width="100%" height="100%">
> &nbs! p; <mx:TextInput name="GridRowCountN" id="GridRowCount! " & nbsp; 
> width="97"/>
> </mx:GridItem>
> </mx:GridRow>
>
>
>
> </mx:Grid>
>
>
> </mx:Application>
>

Reply via email to