Thanks
Thanks

Reputation: 40349

How much does it matter regarding to memory if I create an CALayer rather than an UIView?

While an UIView has a memory footprint of at least 4 * width * height pixels, I wonder how that would look when I create a CALayer only.

Upvotes: 0

Views: 421

Answers (2)

Mark Bessey
Mark Bessey

Reputation: 19782

While an UIView has a memory footprint of at least 4 * width * height pixels

This statement is absolutely not true. The memory overhead of a UIView (compared to a CALayer) is just the size of the instance variables of the UIView class, plus a few instances of additional classes that will get allocated. The UIView instance variables take up about 24 bytes, and the additional data storage is probably the same, or less.

If UIView adds functionality that's useful for your application, then use it. The memory overhead is really of no concern.

Upvotes: 2

Brad The App Guy
Brad The App Guy

Reputation: 16275

Having done some experimenting around this in the past, I found that the added overhead of the UIView object was very minimal.

Upvotes: 2

Related Questions