Img_data_lock iphone - imageNamed vs imageWithContentsofFile

I notice a burst of memory, and the responsible caller specified in the tools is img_data_lock, and the responsible library is CoreGraphics.

I read that the problem is with caching and not with caching image loading ( Difference between [UIImage imageNamed ...] and [UIImage imageWithData ...]? ) Currently, my application uploads a series of images viaimageNamed

replacing the call imageNamedwith imageWithContentsOfFileseems to solve the problem.

Does anyone have any information about the username img_data_lock? Why would anyone use imageNamedit if they require such a board in memory?

+3
source share
1 answer

The UIImage methods imageNamed: and imageWithContentsOfFile: do slightly different things. imageNamed loads the image into a special system cache, and then future calls with this path will return the image to the cache, and not reload it from disk. imageWithContentsOfFile just loads the image at the path you specify, but does not cache. Multiple calls to imageWithContentsOfFile for the same image will result in multiple copies in memory.

iOS, , ( , ), , - . UIImages, imageWithContentsOfFile, , , , , .

, , , , UIImages imageNamed, . !

, , imageName , . , , , : http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/

+13

Source: https://habr.com/ru/post/1747072/


All Articles