uiimage allocation problem
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.
精彩评论