Memory issues in Flex applications


As we all know that for any application runtime memory plays a crucial role. And every technology handles memory clean up in their own way, in fact the API’s offered by the technologies doesn’t guarantees the same.

Few days back I was struggling with my application which is having a UI interface based on Flex. And in one of the interface we started getting out of memory issues,  First of all lots of time goes waste in finding the root cause of the memory issues, Thanks to the debug version of the Flash player 10 who helped us to get the root cause.

There are plenty of things I will detailed to avoid out of memory issues in Flex based applications, I will publish those in my next blog. But as a quick workaround we can call the garbage collector to clean the memory in the Flash Player. Flex 3 System API is having a method called Syatem.gc() but sometime not found working. In flash there is no way to explicitly invoke the garbage collector, but on the web there is a hack(below) that can be found easily.

public static function forceGarbageCollecion():void{ // hack for garbage collection
trace(“Total Memory:”+flash.system.System.totalMemory);
var loclConA:LocalConnection= new LocalConnection();
var loclConB:LocalConnection = new LocalConnection();
}catch (e:Error){
trace(“Error ::”+e);
flash.system.System.gc(); // incase some error occurred, invoke the System Garbage collector
trace(“Total Memory:”+flash.system.System.totalMemory);


Hope this helps!!


R Vashi

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.