Useful Flash Lite Development Tool

March 23rd, 2007 · 1 Comment


For those of you that are developing Flash Lite applications and games you will be well aware of the issues of Memory leaks in the Flash lite player. One area where this can occur is in the creation of "crossed references". These result in objects that are effectively locked as far as Garbage Collection is concerned, and so result in memory 'leaking' over time.

A crossed reference occurs in situations such as this.

[as]
var myFirstObject:Object = new Object();
var mySecondObject:Object = new Object();

myFirstObject.reference = mySecondObject;
mySecondObject.reference = myFirstObject;

myFirstObject = null;
mySecondObject = null;

delete myFirstObject;
delete mySecondObject;
[/as]

In each case the objects above have a property that references an object, and the reference is cyclical in nature. As far as the Garbage Collection routine in the player is concerned each object will always have a usage count of 1 regardless of the delete statements as a result of the reference in the other object. The result is that neither object will be cleared from memory, hence the leak. If such a situation were to arise in a looping operation the loss of memory is compounded.

[as]
var i:Number = 0;
var iTotal:Number = 5;

whie(i < iTotal)
{
var myFirstObject:Object = new Object();
var mySecondObject:Object = new Object();

myFirstObject.reference = mySecondObject;
mySecondObject.reference = myFirstObject;

myFirstObject = null;
mySecondObject = null;

delete myFirstObject;
delete mySecondObject;
++i;
}
[/as]

Now the above example is a very simplistic example, and is very plain to avoid. With more complex applications however, these situations can arise over many classes and may not be any where near as blatant. This little flash extension offers a great interface for highlighting those crossed references in small applications vital for Flash Lite developers to find and remove.

object-explorer

How about donating a coffee, beer or even a round of beers for my efforts here? Thats around £2.50 for a coffee or a pint or about £10 for a round of beers. Cheers!

Tags: ActionScript 2 · Flash 8 · Flash Lite · Mobile Devices · Mobile Phones

1 response so far ↓

  • 1 w // Aug 5, 2009 at 8:53 am

    i just try to solve the problem of memory of flash lite. So i just wanna try your tool

Leave a Comment