Take the 2-minute tour ×

I have created an instance of CALayer using [CALayer layer] and set its frame to the frame of the screen (e.g. 768 by 1024 points). I have not set the contents of this layer. Will this layer take up extra memory because of the larger size, or does the memory consumption remain the same because it has nothing to draw?

share|improve this question
I will post this as a comment since I haven't verified it, but the actual heavy item of any view (or layer) is its backing store which is created on demand. It is basically a bitmap for all the pixels in the layer, so if you haven't drawn or used the layer yet, I assume all you have is a few bytes of metadata. This is the way the new view system in iOS 6 works. Instead of viewDidUnload, the backing store is simply purged while leaving the view variables and properties intact. –  borrrden Nov 6 '12 at 1:43
add comment

2 Answers

up vote 2 down vote accepted

A CALayer basically is just a few properties and methods. So the CALayer itself (almost) doesn't cost memory. If you assign an Image to the contents-property of course then this will cost the amount of memory your Image uses in decompressed (CGImage) form.

(Afaik the CALayer only stores an reference to the actual Image so to be precise the CALayer itself still has almost no memory usage)

To check the memory-usage of your App at runtime use the (very cool) Profiling-Tool:

  1. Build for Profiling
  2. Under run, choose Profile
  3. Choose "Memory usage" (or similar, I'm not sitting at my MAC right now)
  4. Click the red "record"-button on the top-left


share|improve this answer
add comment

If you want, you can check the free memory before and after create the layer. If you want to do that please check this:

Knowing "available RAM" on an iOS device

share|improve this answer
add comment

Your Answer


