Each time you use the "new" keyword to create an object, you put your application on a piece of memory [1]. So, let's say you make uint by writing var exampleUint:uint = new uint(); . ActionScript tells the computer "hey ... I need ... four bytes of memory" to which the computer responds "ok, use four bytes starting with [some memory address, for example 0x7B3208C1]" [2], so when you say var someString:String = "blah"; , you require a space in memory, fill it with some information (in this case it is "blah" ), create a label (in this case it is someString ) and bind a shortcut to this space in memory.
Now the label is not actually associated with the data itself, it is associated with a place in the memory containing the data. This should seem confusing because it is, but for certain reasons it causes a chaste feeling. All objects in the ActionScript reference , which means that the object contains the memory address of some piece of data, not the data itself. This contrasts with objects that are value , where the label is associated with the data itself. Do not worry about the details of value types, because it is not in ActionScript, so for your purposes, I include it strictly for contrast. Okay, embarrassed? You probably should be, because this entire paragraph is completely useless and perhaps even unnecessary, but try to keep it in the back of the head because it may have something to do with your problem.
Now that this label has disappeared (for example, it goes out of scope , now someString does not make sense), only the someString label is someString . So, for this example, if you say someString = null; , the string "blah" actually remains in memory, but the label someString does not refer to this piece of information, it refers to the memory address of a null object (again, details). We need a way to point to the computer "do you know that [whatSize] is a piece of memory that I claimed starting with [whateverAddress]? Well, I ended up with it now so that someone else could use that piece of memory." The Gabage collection is an automatic process to restore your recovered memory without having to worry about it yourself. In non-garbage collection languages, new has an add-on keyword that specifically frees the memory associated with the object [3], but ActionScript does not; you just take a piece of memory and forget about it.
Somewhere along the lines you could create another variable and refer to this piece of data var someOtherString:String = someString; , so we can’t just say "well, the someString label someString disappeared, so let's get rid of the data that it refers to," because we do not know for sure that someString is the only link to this data. The method in which this is done varies between languages ​​and garbage collection systems, but the main deal in ActionScript is this: from time to time (especially if Flash is currently taking up a lot of memory), the garbage collector scans all objects in the current SWF and finds all objects. which do not have a link [4]. So, for our previous example, if someString was the only thing that referenced the string "blah" and someString went out of scope, then "blah" n’t bound to any tags and therefore Flash was completely inaccessible. The next time the garbage collector starts up, it will find it and then report back to the system what it has done with this piece of memory.
Now the specific details of your particular problem will be hard to tell without looking at the source, but I can tell you that one of the problems that often cause problems is event listeners. Sometimes you can create a function and add it as an event listener. Now the event itself has a link to this function [5], therefore, if a function goes out of scope, it still refers to it, and the function does not receive a garbage collector (remember that functions are objects in ActionScript), you can either delete manual event handler by calling removeEventListener (I would not recommend it), or set the useWeakReference parameter when addEventListener () is called to true . A weak reference is not recognized by the garbage collector, so setting useWeakReference to true prevents the situation where you have a function that should be selected by the garbage collector, but this is not because someone refers to it as an event listener. Judging by the large number of mouseEvent listeners in your project, this could be a criminal. If you have Flex Builder, you can use the profiler to find out how many method closures you have; if they rise and never descend, this is probably your problem.
[1]: Keep in mind that this also applies to situations in which you create an object without using the new keyword, for example, if you have to write var exampleInt:int = 5; .
[2]: I chose uint because all uints are the same size, so I can confidently say that I know that it will be four bytes. The lines are different; they take up memory proportional to the number of characters they contain, so it would be a little more ambiguous to use String for both examples.
[3]: the ActionScript delete keyword is not for this purpose, so do not try to use it that way, although it would make logical sense, and it would be very useful. [4]: Flash uses a mark-and-sweep style strategy, more specific details of which can be read here . [5]: In fact, the bold type lies because the addEventListener method uses closure , but I have a rather poor understanding of this to start with so I cannot weld it in a normal person.