ios - Is it wasteful to repeatedly reload the same spritesheets into the frame cache? -
currently, have menu scene in add spritesheets framecache. repeatedly go away menu scene , go back. thus, every time menu scene reloaded, same spritesheets added framecache. bad thing? old ones overwritten, ignored, updated, kept? leaking memory or wasting memory readding same spritesheets framecache on , on again?
it neither wasteful nor harmful. key components behind cctexturecache , ccspriteframecache singletons. both using nsmutabledictionary, under hood. when 'reload' texture, if keyed cache, 'add' action silently omitted (ie texture not reread , reloaded), , invoking method returned appropriate texture 1 in cache.
for sprite frame cache, when .plist read, sprite frame object created, embedded ccspriteframe set each key in plist. thus, when reload, previous ccspriteframe objects released (assuming not retaining them somewhere else in code, example if retain ccanimation refers them).
the actual resources have concern time , memory. when leave menu, if 'destination' memory constrained, remove unused textures , unused sprite frames before allocating resources required there. having done that, when come menu, texture re-read , re-loaded (there little impact ccspriteframe's). must determine whether introduces unacceptable lag, , base decision remore unused textures on ... please, on device, not simulator.
Comments
Post a Comment