Memory management in Flash
This article discusses how Flash moved from reference counting to garbage collection for their ActionScript implementation.
They decided to make the change for efficiency: the memory and cpu overhead for maintaining reference counts in large Flash applications was getting noticeable. Circular references (leading to leaks) were a secondary issue.
Another article gives some numbers: the overhead of reference counting was about 20% of runtime, and the overhead of the new garbage collector is only 1–2%. (The collector is an incremental mark and sweep collector.) Also, memory use is reduced by about 50%.
I don’t consider this to be a nail in the coffin for reference counting. We’ve seen with Cyclone that a mix of memory management strategies can give the greatest efficiency. Most applications can get by with stack and (lexical) region allocation for most objects, and only rarely need the additional capabilities of reference counts. Moreover, autorelease can eliminate a lot of the overhead of maintaining counts.
On the other hand, it would be nice to find out more details: was every object reference counted? what is the “deferred reference counting” optimization they used?
13 April 2006 by trevor #