memory - Allocating vs. reusing in Objective C -
as thumb rule, what's better?
- allocating new instances (in case of uiviewcontroller) when need them , deallocating ("releasing" retain of them , therefore allowing them deallocated arc) when i'm finished, or;
- maintaining dynamic pool of reusable instances , therefore keeping them in memory when they're not used.
the way see it, allocating new instances can hard work avoids bug due unexpected state of reused instances, , burden in memory of more instances needed @ specific time.
would love hear thoughts it...
premature optimization waste of time. until have quantified performance issue, there no optimization done beyond keeping code sensible , using reasonable algorithms.
in case, quite allocating anew each time not going actionable source of performance bottleneck. however, tasks performed during allocation may be. example, creating images or loading resources instead of using cache of kind.
but such bottleneck better addressed through caching said resources , not relatively macro object view controller.
Comments
Post a Comment