I'm experimenting with dynamically created and destroyed script objects with ancestors (strange how the child object seems to create the ancestor instance????). Some of these create and use image objects during their life span, referenced by the scripts own properties. My main question is if I set the reference to the script object to VOID or zero do the image objects created by the script get garbage collected as well?
Or do I have to create some custom on ~ destroy() style handlers for each script and remember to zero each image object /ancestor that the script instance creates?
Any memory management advice much appreciated in general!
As long as the only reference to the image object is a property of a script object, as soon as the script object is garbage collected (its reference count drops to zero) the image object will be disposed with and its memory freed. However, there's nothing wrong with playing it safe and doing some of this yourself, like your theoretical "on mDispose()" handler.
Thanks for your time!
Good to know how it works behind the scenes.