Friday, May 23, 2008

All Flex developers should know this

I sort of thought I didn't have to worry about memory leaks in Flex, because garbage collection would come to my rescue and sweep away the cruft. However, after what I learned last night (links below), I am reminded of a friend's favorite interview question: is it possible to have memory leaks in Java?

My friend would ask this and the greener candidates would emphatically reply, "No!" He liked asking that question, because he knew there were ways to leak memory in Java despite all the hype about garbage collecting. Sure, in most cases you don't have to worry about cleaning up after yourself. But I guess the smarter folks (not me) just know that it all depends on what you're doing and how you do it.

I stumbled on this post from Dan Schultz, who gives some nice tips on when to use weak or strong references when you add an event listener in Flex. Dan references another article from David Colleta which provides a little more insight.

I am using a Timer in a project that I'm working on, and fortunately I learned this before I had to trouble shoot the associated problems of using the wrong type of reference in my code.

Thanks, guys!

No comments:

Post a Comment