# How would these DisplayObjects be garbage collected?

**URL:** <https://forum.kirupa.com/t/how-would-these-displayobjects-be-garbage-collected/327062>\
**Category:** flash\
**Created:** [February 3, 2012, 7:54am UTC](https://forum.kirupa.com/t/how-would-these-displayobjects-be-garbage-collected/327062 "2012-02-03T07:54:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AS3\_Gringo](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@AS3\_Gringo](https://forum.kirupa.com/u/AS3_Gringo)\
**Post date:** [February 3, 2012, 7:54am UTC](https://forum.kirupa.com/t/how-would-these-displayobjects-be-garbage-collected/327062/1 "2012-02-03T07:54:37Z")

</div>

Let say there is a Class A, it has a timer which updates its x position periodically. So all the instance of Class A will update their own x position. There is another Class B which extends Class A and overrides the function which updates position to change y position and call the trace function.

Now what I do now is create two instance alpha1, alpha2 of Class A and other two instance beta1, beta2 of Class B.

- alpha1 is only instantiated, but not added to the stage.
- alpha2 is instantiated, and there after added to the stage.
- beta1 is only instantiated, but not added to the stage.
- beta2 is instantiated, and there after added to the stage.
- let say after few seconds, I remove alpha2 and beta2 from stage.

Now suppose the GC fires collection, who all would be collected ?

Please do consider this a question from a naive developer.

Humble Regards,  
AS3 Gringo
