I want to know if using “ass. getTextures (” role_ “)” multiple times to create a “MovieClip” will generate a large amount of memory?
var c1:MovieClip = new MovieClip(ass.getTextures(“role_”), 12);
var c2:MovieClip = new MovieClip(ass.getTextures("role\_"), 12);
var c3:MovieClip = new MovieClip(ass.getTextures("role\_"), 12);
var c4:MovieClip = new MovieClip(ass.getTextures("role\_"), 12);
var c5:MovieClip = new MovieClip(ass.getTextures("role\_"), 12);
var c6:MovieClip = new MovieClip(ass.getTextures("role\_"), 12);
I’d like to suggest even from an efficiency standpoint, repeating the same call each time could be avoided. Under the hood it has a bit of repeated work to do each time, and it’s avoidable.
Perhaps instead, something like this:
var roleTextures:Vector<Texture> = ass.getTextures("role\_");
var c2:MovieClip = new MovieClip(roleTextures, 12);
var c3:MovieClip = new MovieClip(roleTextures, 12);
...
As for the memory question, to be honest I’ve not tested it. My approach to this issue has always been defensive, because the applications I build typically need 24/7 uptime and stability.
I create once → re-use many.
If you are needing to remain as slim as possible in terms of system memory, then perhaps a create → destroy → cleanup ↲ approach is needed.
If within a class you’re expecting to keep needing those textures (create → destroy → cleanup ↲), then I’d even suggest holding those textures in a class variable that sticks around.
It retains a persistent reference to those textures for re-use during runtime, and helps reduce pressure on the garbage collector.