开发者

uiimage allocation problem

开发者 https://www.devze.com 2022-12-17 22:53 出处:网络
I have 3 UIImages in UIScrollView and I am initializing these images in the follo开发者_StackOverflow中文版wing way:

I have 3 UIImages in UIScrollView and I am initializing these images in the follo开发者_StackOverflow中文版wing way:

UIImage *dimage = [[UIImage alloc] initWithData:data];

Where data is a NSdata gotten from url request. After this I am caching the images. When I check memory allocation the 3 images takes up 472 Kb each and allocation has been requested by "img_data_lock" from CoreGraphics library. When I check size of that image on disk cache it was 230Kb each.

I dont know how can it take more space. I hope my question is clear.


Not sure what "disk cache" you're looking at but memory and disk usage are only weakly related. The data used to create an UIImage is only part of the data the object actually uses. This means an active object will can use more memory than the data that created it.

To further complicate things, UIImage will purge itself of image data under low memory situations so size of UIImage object can vary widely over the course of its existence.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号