Director FAQ [14] Objects, Parent Scripts & Factories [14.10] Do I need to dispose of these objects when Im done?
In general, child objects birthed from parent scripts dispose of themselves as soon as there aren’t any variables around the place referring to them: since you can’t use them if you don’t have a reference to them, Director takes the opportunity to trash them and reclaim the memory they used. However, there may be cases where references are kept not in variables, but in lists or the properties of other objects. As discussed in section 12.8, if a circular reference arises (if, for example, your object keeps a reference to itself — not as outlandish as it may seem, honest guv — or keeps a reference to another object which in turn keeps a reference to it, etc), the memory occupied by an object may be lost to your movie permanently. If your objects are simple, and don’t cross-reference one another, it should usually be sufficient to clear out any object variables that you’re no longer using. If they’re kept as globals, they’ll stay around until you set them to something else, or issue a c
Related Questions
- Director FAQ [14] Objects, Parent Scripts & Factories [14.9] How are factories different from parents, and is there any reason to use them instead?
- Director FAQ [14] Objects, Parent Scripts & Factories [14.7] I want to put objects on the stage on the fly. How do I allocate channels?
- Director FAQ [14] Objects, Parent Scripts & Factories [14.6] Do objects always relate to sprites?