Hi All,
?I had posted this query to couple of other groups ..I am still struglling with this issue..Hope someone?will?help me out here
?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
- 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 also created scalled down war file which can be deployed on any?java application server.
Any help will greatly be appreciated
Regards,
Dam
######################## MXML##########################
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute''
?creationComplete=''init();'' height=''100%'' width=''100%''
%26gt;
%26lt;mx:Script %26gt;
%26lt;![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;
?
}
?
]]%26gt;
%26lt;/mx:Script%26gt;
?
?%26lt;mx:DataGrid id=''tradeList''
initialize=''tradeList.dataProvider = tradeCollection'' horizontalScrollPolicy=''auto''
height=''659'' x=''0'' y=''84''%26gt;
?%26lt;mx:columns%26gt;
%26lt;mx:DataGridColumn?headerText=''Security Description'' dataField=''securityDesc''
?/%26gt;
%26lt;mx:DataGridColumn?headerText=''B/S'' dataField=''transactionType''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Amount'' dataField=''amount''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Price Text'' dataField=''priceText''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Counterparty'' dataField=''counterParty''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Trade Date'' dataField=''tradeDate''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Settle Date'' dataField=''settleDate''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Trade Status'' dataField=''tradeStatusId''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Trader'' dataField=''trader''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Salesperson'' dataField=''salesperson''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Ticket Number'' dataField=''tradeNumber''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Entry Date'' dataField=''tradeTime''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Cancel Date'' dataField=''cancelDate''
/%26gt;
%26lt;mx:DataGridColumn?headerText=''Cancel Time'' dataField=''cancelTime''
/%26gt;
?
%26lt;/mx:columns%26gt;
?%26lt;/mx:DataGrid %26gt;
%26lt;mx:Grid x=''149'' y=''23'' width=''995''%26gt;
%26lt;mx:GridRow width=''100%'' height=''100%''%26gt;
?%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:Label text=''Enter No of obejcts'' width=''111''/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:TextInput name=''row'' id=''rowData'' width=''97''/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:Button?label=''Load Data'' click='loadData()'/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:Button?label=''removeAll'' click='removeAll()'/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:Label text=''Total Memory''/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:TextInput text=''Total Memory'' id=''memory'' width=''97''/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:Label text=''Grid Row Count''/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;mx:GridItem width=''100%'' height=''100%''%26gt;
%26lt;mx:TextInput name=''GridRowCountN'' id=''GridRowCount'' width=''97''/%26gt;
%26lt;/mx:GridItem%26gt;
%26lt;/mx:GridRow%26gt;
?
%26lt;/mx:Grid%26gt;
?
%26lt;/mx:Application%26gt;
Hi,
try to call removeEventListener(...) for all objects you created and set eventListeners.
Write about results.
Memory Leak In DataServiceHi Natasha,
Sorry for late reply.
?I tried your suggestion but It did not help to release memory. Actully,this app contains only one event handler which is for remote method call , I dont think this could cause any memory leak.
Profiling session reveals that It is the issue of DataService class.I dont know How do I convince?Adobe to investigate this issue.
Regards,
Dharmendra
No comments:
Post a Comment