views:

311

answers:

1

I have few questions related to UIColor and UIFont.

  1. I am wondering how heavy will it be on the system if I allocate a bunch of UIFonts and UIColors at the startup time, that I need for the duration of the application running.

  2. Is it expensive to create UIFont and UIColor at run time? Will it improve performance in any way if I pre allocate the same.

+5  A: 

Create them when you need them. Remember that memory is important and Apple do some heavy lifting for you. Trust the OS optimisations on colours and fonts.

Roger Nolan
How do I find out how heavy it is on the system? Lets assume I have an image that I want to use to draw the background and draw some gradient on top of it. How do I effectively measure how much heavy will this be on the system if I keep this hanging around, assuming its speedier performance wise. I am looking how to benchmark performance vs memory here.
siasl
The best advice I can offer is to get your code working and they optimise it. See how it performs in actual usage conditions and optimise the slow areas. Apple give you some powerful tools to inspect many aspects of the system but you should only do this when the entire system is working together.Do not worry about specific things that you expect to be slow. (or that other people tell you are likely to be slow...)
Roger Nolan