If an object is garbage collected in Flash, are the reference counters of objects it references decremented automatically?

Shameless self promotion, but this should help you: divillysausages.com/blog/tracking_memory....

2 If you want to link to your article, your answer ought to show how it's relevant to the question. – BoltClock? Jun 20 at 21:29 I think the link spells it out: tracking_memory_leaks_in_as3.

But, yeah, would be nice to give a little summary. (Makes a more effective self promotion too. ) – Plastic Sturgeon Jun 20 at 21:35 good points :) it covers the basics of as3 garbage collection, both the reference counting method and the mark and sweep, as well as giving you a tool to help track memory leaks and easily see if objects are getting properly deleted, plus how to call the garbage collector in debug and release mode – divillysausages Jun 20 at 21:57 also, @jeff, both flashdevelop and flash builder come with profilers that let you see how many objects were created and how many are still alive – divillysausages Jun 20 at 21:58 thanks for the link; very informative!

Also, I found an open-source alternative to the Flash Builder profiler here: jpauclair. Net/flashpreloadprofiler Haven't gotten to test it out yet, but its demos look great. – jeff Jun 20 at 22:26.

I don't think of AS3 in terms of reference counting. If those objects created in Button1 are only accessible via Button1, then they're eligible for GC once you null out Button1. The exception is event listeners, you have to clean those up or those objects won't get cleared out.

Flash doesn't take into account no objects are listening anymore.

The issue is I don't want to end up with ref counts for objects 'shared' between classes that can never reach 0 because another object that made reference to them no longer exists but failed to explicitly null out the references it made before it was GC'd. If refs made by an object are automatically nulled out when it is GC'd, this is not an issue.So that's the question really-- are references made an object nulled out when it is GC'd? – jeff Jun 20 at 22:02 To the best of my knowledge, you don't need to worry about the reference count.

If Object1 and Object2 both reference Object3, Object3 will be eligible for GC once both references are nulled out, timing of when those do that doesn't matter. – SkellyB Jun 21 at 19:58.

This presentation onflex.org/ACDS/AS3TuningInsideAVM2JIT.pdf has a pretty good description of how garbage collection is implemented in AVM2 (the virtual machine that runs AS3).

Ooo, a good question :) As far as I know, Mark and Sweep is only used for reference counting event listeners since they're the only ones that can have 'weak listeners'. Everything else is straight up memory reference counting. Essentially, your biggest problem would be cleaning up event listeners, but if the event listeners are within your class (listening to itself, or it's children or even outside events) they should be GC'ed properly if the object is dereferenced throughout your app (don't store it somewhere else).

If you let object or properties be publically visible, it is possible for other classes to references them and it could prevent GC of your class (it really depends how it's referenced and all). The only to combat that is to try to encapsulate as much as possible (one class handles it's own dereferencing; look into IDisposable) so that others can't reference and try to adhere to good coding practices (preventing spaghetti code).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions