Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

dispose method in flex

Posted on 2008-10-12
7
Medium Priority
?
2,152 Views
Last Modified: 2012-08-13
I have a flex app that uses a webservice to communicate with a sql server database.  I make calls to the webservice through flex, the webservice callse the database and returns the data in XML format and Flex parses the data as necessary(i.e. - to display in datagrids or comboboxes, etc.).  The app seems very slow...I am wondering if it is because it is still holding the xml data in memory...does Flex have a dispose or finalize method similar to .Net?  I have included an example of my code.
public function GetAssigneeTypes():void
	{
		var ws:WebService = Program.m_webServiceManager.getWebservice();
		ws.GetAssigneeTypes.addEventListener(ResultEvent.RESULT,LoadAssigneeTypes);
		ws.GetAssigneeTypes();
	}
	public function LoadAssigneeTypes(e:ResultEvent):void
	{
		Assigneetypes = new ArrayCollection;
		var dataSet:DataSet = new DataSet(String(e.result));
        if(dataSet.HasErrors())
        {
        	Alert.show(dataSet.GetErrorAt(0));
        }
        else
        {
        	var dataTable:DataTable = dataSet.GetTableAt(0);
        	{
	       		var keyPair:KeyPair = new KeyPair();
	       		keyPair.Name = "";
	        	keyPair.Value = "Assignee type"; 
	        	
	        	this.Assigneetypes.addItem(keyPair);
        		for(var index:int=0;index<dataTable.RowCount();index++)
        		{
        			var row:DataRow = dataTable.GetRowAt(index);
        			keyPair = new KeyPair();
	        		keyPair.Name = String(row.GetValue(0));
	        		keyPair.Value = String(row.GetValue(1)); 
	        		this.Assigneetypes.addItem(keyPair);
	       		}
        	}
        }
	var ws:WebService = Program.m_webServiceManager.getWebservice();
	ws.GetInitiators.addEventListener(ResultEvent.RESULT,LoadInitiatorTypes);
	ws.GetInitiators();
	}

Open in new window

0
Comment
Question by:PsychoDazey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:Savong
ID: 22704275
Unless your XML is absolutely huge I doubt the slowdown comes from keeping the XML.  If the XML doesn't have current references to it it ought to be garbage collected (similar to Java).  Have you run the profiler on your code, or tried tracing out Timer values to see where the slowdown is really happening?
0
 
LVL 6

Author Comment

by:PsychoDazey
ID: 22704379
No, I haven't, I'm not sure how to run the profiler.  I am also re-writing some code because it is making 6 calls to the database to get 6 lists.  I am going to change it so it makes one call to get 6 different data sets then parses them...what do you think of that?
0
 
LVL 10

Expert Comment

by:Savong
ID: 22704452
That should certainly speed up the process as calls for external data often slow down the whole process (particularly if they are called serially).  Here are a couple of links for more info on the profiler built into Flex Builder 3 if you have it available:

http://www.onflex.org/ted/2008/09/360flex-sj-2008-using-flex-builder-3.php
http://livedocs.adobe.com/flex/3/html/help.html?content=profiler_3.html
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 6

Author Comment

by:PsychoDazey
ID: 22704464
Thanks, i'll check into that.
0
 
LVL 6

Author Comment

by:PsychoDazey
ID: 22751073
hi savong -
making one call instead of 5 or 6 calls in serial made a huge difference in speed.   Unfortunately, I dont have flex3 so i cant run the profiler to see if I am holding alot of data in memory.  Instead of dispose, should I be clearing out all of my arrays when I navigate away from the page they are used on? If so, how and when do i call the removeall method?
If you feel this is out of the scope of this question just let me know and I will open a new one!

Thanks!
0
 
LVL 10

Accepted Solution

by:
Savong earned 2000 total points
ID: 22759706
Basically any variables you want to be garbage collected should be set to null so that there is no longer any reference to the object.  Grant Skinner has a number of good articles on references and garbage collection for flash:
http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
http://www.gskinner.com/blog/archives/2006/07/as3_weakly_refe.html
http://www.gskinner.com/blog/archives/2006/06/understanding_t.html
0
 
LVL 6

Author Closing Comment

by:PsychoDazey
ID: 31505488
Thanks again!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question