Donelson
asked on
garbage collection: arrays
If I have a large array
theArray:Array = new Array();
and I add 50,000 elements etc. then need to "flush" all those elements...
Should I use --
theArray = [ ] ;
Will that do it? OR should I use :
theArray = new Array( );
to ensure that the previous contents are garbage-collected ?
Please explain for ---> BOTH Flash 7 and Flash 8 ...
Thanks
theArray:Array = new Array();
and I add 50,000 elements etc. then need to "flush" all those elements...
Should I use --
theArray = [ ] ;
Will that do it? OR should I use :
theArray = new Array( );
to ensure that the previous contents are garbage-collected ?
Please explain for ---> BOTH Flash 7 and Flash 8 ...
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The thing is that delete is meant to get rid of references, in order to get rid of the movieclip, you're going to have to do something like theArray[5].unloadMovie();
theArray[5].removeMovieCli p();
delete theArray;
Chances are that if you're using theArray to contain references to MovieClips, then you're going to have to loop through the array and delete the movieclips manually and then finally delete the entire array.
--trigger-happy
theArray[5].removeMovieCli
delete theArray;
Chances are that if you're using theArray to contain references to MovieClips, then you're going to have to loop through the array and delete the movieclips manually and then finally delete the entire array.
--trigger-happy
ASKER
Thanks, TH. Yes, that is what I'm doing, but I was curious as to the garbage-collection of "unreferenced objects" that Flash is supposed to do. It must be that movieClips keep their reference on the _root (etc) so are not automatically gc'd.
ASKER
NOTE:
If I say --
theArray[5] = createEmptyMovieClip("foo"
then say
delete theArray;
then the movieClip "foo" does not go away ever, but the array does. (looking at the _root objects)