Force Garbage Collection in AS3?

Yes, it’s possible, but it is generally a bad idea. The GC should have a better idea of when is a good time to run than you should, and except for a very specific case, like you just used 500MB of memory and you need to get it back ASAP, you shouldn’t call the GC yourself.

In Flash 10, there is a System.gc() method you can call (but please don’t, see above) – keep in mind System.gc() only works in the debugging version of Flash player 10+.

In Flash 9, there is an unsupported way to force it via an odd LocalConnection command, but it may not work in all versions. See this post by Grant Skinner.

Leave a Comment