How much does it matter regarding to memory if I c

2019-08-24 13:53发布

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.

2条回答
聊天终结者
2楼-- · 2019-08-24 14:19

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

查看更多
SAY GOODBYE
3楼-- · 2019-08-24 14:19

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.

查看更多
登录 后发表回答