

Action Script 3 Memory Management - epochwolf
http://tomgabob.blogspot.com/2009/11/as3-memory-management.html

======
reitzensteinm
I've been developing relatively large and complex games on the Flash platform
for a while (see: <http://www.rocksolidarcade.com>), and if I put into words
just how badly made I think the entire platform is, I would expect to get
written off as a troll.

With that said, the garbage collection is actually pretty decent. It's one of
the few (perhaps only) parts of the entire ecosystem where I've never found
any hair pulling, WTF worthy bugs.

------
pl0nk
> Making sure every "new" was matched by a "delete" was tedious but absolutely
> necessary

Anyone who thinks this is necessary should check out boost::shared_ptr,
weak_ptr, and scoped_ptr:

[http://www.boost.org/doc/libs/1_42_0/libs/smart_ptr/smart_pt...](http://www.boost.org/doc/libs/1_42_0/libs/smart_ptr/smart_ptr.htm)

C++ has been around long enough to have had several distinct epochs of style
and best practice. It's not necessary to do much manual heap management in
modern C++.

And the subtle upside of using ref-counting is that the ownership and lifetime
of your data becomes self-evident in the types. It takes awhile to appreciate
that, but it makes garbage collection feel a bit like dynamic typing: yes, it
requires you to think less, and there are heroic, inspiring optimizations
behind it, but ultimately makes it harder to understand the runtime behavior
based on just looking at the code.

This post is interesting because he's identifying those limitations of GC:
he's ending up having to add reference management to his GC code, by making
sure to null out references, etc. It's nice to have the type system do that
for you.

------
liuliu
I am really not sure about the tip #1. Isn't that the main advantage for GC
when comparing to reference counting because it can recognize circular
referencing etc?

