March 28th, 2007
Adobe releases their GC-files…
Garbage Collection and memory management have been on the mind for those of us who have been developing Flex applications, namely ones that require long periods of operation or large and numerous file support.
As we try to debug our applications and find more information on GC we’ve realized that there are no tools and hardly any information on the topic…that is until now.
During past projects I had email correspondence with Kyle Quevillon a Senior Support Engineer for the Flex product line at Adobe. During our troubleshooting process he shed some light on some of the internal garbage collection and memory management specifics regarding the Flash Player and Flex development. At the time he even provided some memory test utility code which was very helpful in diagnosing the issues. The good news, the dialog I had with him was a very common occurrence with Adobe support and their Flex customers, and thankfully the dialog and memory test code has been posted to his blog, thanks Kyle!
Back on March 16th, I attended Apollo Camp. I had been working with the alpha release candidates and had a pretty good feel for what Apollo has to offer. Luckily for me, this meant that I could take full advantage of the “Ask the Experts” room they had in the back corner fully populated with all the Flex and Apollo bad asses on the Adobe starting lineup.
With my access to “Ask the Experts” I just couldn’t wait to hop into the room and talk about GC, memory management, and best practices. This resulted in a very in-depth and enlightening conversation on the topic with Alex Harui a very knowledgeable Adobe Engineer…sorry Alex, I don’t have your official title.
Well, after 11:30pm hit, the Adobe office where they were holding the Apollo Camp turned into a pumpkin, and I was ushered back into the real world…since the camp it had been my intention to blog about what I had discussed with Alex, I had an extensive set of notes written and ready to be massaged and published sitting on my pda phone.
The good news was that during my discussion with Alex, he had mentioned that he needed to consolidate his thoughts onto a blog somewhere…thanks Alex! Alex’s post has a link to a very good presentation he had done on Flash Player GC, and looking at the notes on my pda phone most all of them were covered in the presentation.
So, the Flex community should thank both Kyle and Alex for releasing this information, not to mention the example code and Powerpoint presentation you can download from their blog posts. I certainly am grateful.
In closing, double checking my notes with theirs, I did see a couple of interesting omissions, that I figured I’d bring up here:
- If you have a variable that references the innards of an object and not the object itself, that will not count as a reference to the object. For instance, if you have an ArrayCollection of Human objects, you create a variable of type Human and reference one of the Human objects within the ArrayCollection this will not count as a reference to the ArrayCollection.
- Alex had mentioned that there were two known GC related memory leak bugs caused by the Flex Framework:
- If you use PopUps that have ComboBoxes in them, when the PopUp is removed and garbage collected, the ComboBox will remain since the PopUpManager is still holding a reference to the ComboBox
- When you implement a navigator container such as a TabNavigator or ViewStack and make use of the HistoryManager, the way that references to the HistoryManager and back again are created, causes an issue with the garbage collector when it goes to count references.
- For those of you that have entertained the thought of using destructor functions like in C++, don’t bother. Reason being, destructor functions are usually used to free memory, and that’s handled by the Flash Player garbage collector. However, one thought about a destructor that you may want to extrapolate would be to have a cleanup function or even a manager to remove event listeners, references, etc. That’s something you can read more about at the Skinner blog. (Starting on slide 30 he discusses an IDisposable interface and a Janitor utility class)
- Since MAX 2006 we’ve all been waiting for the Flex Profiler to help us debug our memory management issues. I’m sure that at times that we’ve also felt that Adobe was being mean, and holding out on us…I’ve seen plenty of cries within the newsgroups and blogosphere to just release it. Well, I can tell you now that according to Alex, the reason for the hold up is that the profiler UI uses some new functionality in the Flash debug player that won’t be released until Moxie is released. In other words, they could release the Profiler now, it just wouldn’t do anything useful.
Anyway, I’ll be excited for Moxie and the new Flex Profiler, it should make memory management troubleshooting much less painful. In the meantime, it was good to see these recent posts from the Adobe folk!


