Garbage collection with SWF loading
I ran some performance tests today. I made an interesting discovery. When you load a SWF that has elements exported for ActionScript, the class definitions of these elements are stored in the application’s domain and take up memory (we already knew that). But whether you load these definitions into the SWF’s context or your main application’s context will determine whether that memory is ever released.
I tried loading SWFs using the Loader class and unloading them immediately after the load completes. These SWFs contained symbols that were exported for ActionScript (linkage). When providing a LoaderContext with its applicationDomain property set to ApplicationDomain.currentDomain, even if you unload the SWF, memory of that symbol definition is never released. However, if you do not provide one, when you unload the SWF, memory is released.
Conclusion: if you are to use linked library symbols in your projects, avoid loading it in the application’s domain for performance reasons. In one of my projects, I used it intensely and my application lagged and crashed after a few hours of use (could be much less depending on the size of the symbols that you have).
PHP Quebec is pleased to announce the seventh edition of the PHP Quebec Conference. The Conference will take place in Montreal, Canada between March 4 and 6th, 2009. We are looking for speakers willing to share their expertise with Canadian and United States PHP professionals.
Recent comments