UIImageView的内存大小
我想知道 UIImageView
对象的内存大小,因为我需要显示一些大图像并且需要处理内存。我猜这是由图像属性决定的。但我不知道如何计算精算内存大小,下面是我编写的测试代码:
//1.jpg has a size of 4016X2657 and 2.1MB
NSData *imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpg"]];
NSLog(@"imageData:%d",[imageData length]);
控制台显示:
imageData:2070461
这正是 2.1MB 的大小。
但是,在我看来,UIImageView 应该知道显示图像的每个像素,换句话说,它应该具有以下内存: <代码> 4016*2657*4/1024/1024 = 40.7+MB 太大了,不知道iOS会不会做一些优化,而且文档里也找不到相关的。
谁能帮我看看 UIImageView
对象的确切内存大小是多少?
I'd like to know the memory size for a UIImageView
object as I need to show some large image and I need to handle the memory. I guess it is decided by the image property. But I'm not sure how to calculate the actuarial memory size,and below is the code I write to test:
//1.jpg has a size of 4016X2657 and 2.1MB
NSData *imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpg"]];
NSLog(@"imageData:%d",[imageData length]);
The console shows:
imageData:2070461
This is exactly the size of 2.1MB.
However, in my opinion the UIImageView
should know the each pixel to show the image and in other words it should have a memory of :
4016*2657*4/1024/1024 = 40.7+MB
It is so large and I don't know whether iOS will do some optimization or not.And I also can't find any relevant in the document.
Could anyone help me what is the exactly memory size of a UIImageView
object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题中对此进行了描述。内存是照片的精算大小,UIImage不会做优化。
It is described in the question. The memory is the actuarial size of the photo and UIImage will not do optimization.