如果创建CALayer而不是UIView,那么对内存有多大影响? [英] How much does it matter regarding to memory if I create an CALayer rather than an UIView?

查看:94
本文介绍了如果创建CALayer而不是UIView,那么对内存有多大影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管UIView的内存占用量至少为4 *宽*高像素,但我不知道仅创建CALayer时的外观。

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.

推荐答案


虽然UIView的内存占用量至少为4 *宽*高像素

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

此陈述绝对不正确。 UIView的内存开销(与CALayer相比)仅仅是UIView类的实例变量的大小,加上一些将要分配的其他类的实例。 UIView实例变量大约占用24个字节,并且额外的数据存储可能相同或更少。

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.

如果UIView添加了对您的应用程序有用的功能,则使用它。内存开销确实不重要。

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

这篇关于如果创建CALayer而不是UIView,那么对内存有多大影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆