memory - Allocating vs. reusing in Objective C -


as thumb rule, what's better?

  1. 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;
  2. 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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -