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 just to simulate the actual application
What happens , 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 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;
}
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.text ,GUIID);
tradeList.dataProvider = tradeCollection;
}
Remove Data 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();
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
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 also created scalled down war file which can be deployed on any java application server.
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;
import mx.utils.StringUtil;
import mx.events.CollectionEvent;
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;
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;
private function init():void {
var guiId:String ="TEST";
createDestination(GUIID);
}
public function getData():void{
// memory.text =""+ ((System.totalMemory / 1024)/1024);
}
public function releaseDataServices():void {
// tradeService.fill(null);
tradeService.release();
// tradeService.releaseCollection(tradeCollection);
tradeService.channelSet.disconnectAll();
tradeService.disconnect();
tradeService.logout();
//tradeService.dataStore = null;
}
/*Function for creating destination*/
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 error to MATS app
}
}
public function removeAll():void{
if(tradeList.dataProvider){
tradeCollection.source = new Array();
tradeList.dataProvider.source = new Array();
tradeList.dataProvider = null;
}
tradeService.release();
// tradeService.releaseCollection(tradeCollection);
tradeService.channelSet.disconnectAll();
tradeService.disconnect();
tradeService.logout();
System.gc();
}
public function loadData():void
{
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"
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"
/>
<mx:DataGridColumn headerText="Price Text" 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"
/>
<mx:DataGridColumn 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"
/>
</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"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<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>
<mx:GridItem width="100%" height="100%">
<mx:Label text="Total Memory"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput text="Total Memory" id="memory" width="97"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label text="Grid Row Count"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput name="GridRowCountN" id="GridRowCount" width="97"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:Application>
Views
Replies
Total Likes
Hi Guys,
Please have a look on my post .. I really need some pointer to solve this issue ..I have got few more days beofre my client scrap this project..
I will appreciate any on this ..
Thanks In Advance ..
Regards,
Dharmendra
Views
Replies
Total Likes
Views
Likes
Replies