Day: April 11, 2008

Garbge Collection and ActionScript

Performance has been a buzzword for all of us who are into writing super fast applications and with Flash games it has been more so important. As, I started to move into Flex, this was one of areas that I wanted to get a hang on real fast. No one wants, to write code that is not per formant and no one wants to come back and fix code that is not performing.

So, in came Garbage collection in Action script, and I tried a simple and very straight forward spike. I created two buttons and placed then in a Canvas. Then on click on a button i removed the other button. I kept on checking on for quite some time, if the GC had collected the resources, but it did not.

Lesson 1: Garbage Collector does not run as soon as you remove a control. It will run when it is needed. It will check upon system resources like available memory, stack, heap and decide when to collect.

It dawned upon me how would then I know when it collects and how do I optimize or in other words how do I make sure that when a GC collects, it will find what I want to destroy. Complicating the scenario, this is an issue when you have many screens in the application as re-usable objects (creating modules and that can be reused. So, a strategy that comes to mind is what I learned in ASP.NET to have an initialize() and destroy() methods. When I want to load the view for the first time (create) or navigate back in, then i use the initialize() to add all event listeners and when I navigate out, then use the “destroy()” to remove all the events listeners.

This keeps things really simple and also ensures that you will not end up have memory hogged.

Lesson 2: Make sure that you are cleaning up your trail as you move on. Do not leave bread crumbs for monsters to catch up.

I am still learning, so I will continue to post more.

Welcome to my NEWS section

Not many people get a chance to find out what companies are upto? Given that I am finding some information, I am using this News section to publish things happening not just at Adobe + some of the other areas as well. I will try to post once in 2-3 days containing some of the headlines so that if you miss out on any earlier, you do not now. If you find any duplicate, please bear with me.


Open Source at Adobe

Adobe’s take on open source development and it’s role in supporting those initiatives. Read more…

ActionScript 3 RIA Reference Guide

Has all the needed references for all native ActionScript APIs for Adobe technologies. Read more…

Flex is turning out to be fun

I ended my day yesterday, with quite a few things getting done, while other still open, but for sure it was a reveling experience. Flex was all over me most part of the day yesterday. Seems like catching up as I was on top the day before 🙂 I said, I am liking it a lot.

This day some of the big ticket items that I worked upon were:

  • Synchronous event processing – we were facing a lot of issues controlling the events as they get fired and how do we control the sequence as one could be dependent on the other. Tried using the Cairngorm ‘s SequenceCommand. It works fine to dispatch events, but there is no way to go back to the previous event. The final solution is not there yet, but very close to what I want it to be. I think I will end up extending the Cairngorm framework to manage the same in the long run
  • Command Pattern usage in Cairngorm: Does most of it, but the usage of the Command Deisgn pattern is missing. I need a few things in the long run which would lead me to extending the framework
  • Layouts: Got a good grip on how to designing the layouts in Flex and have many areas of comparison. I am in a good position to write an article
  • Runtime Shared Libraries: Some progress there as well. Got the resources to work with the RSL, still have to get my code built as an RSL

If you have already been through some of these, point me to some of those, meanwhile I will continue to work on providing detailed article to all of you.

I am now going back to have fun, you should too.