I ran my application in Tools with VM Tracker and discovered the growing memory consumption of Image IO.

In fact, the application did quite a bit of reading images from disk using initWithContentsOfFile: I read once that this method was Satan's caviar, so I replaced it with the following:
NSData *data = [NSData dataWithContentsOfFile:path]; UIImage *image = [UIImage imageWithData:data];
This reduced virtual memory significantly (about 60%), as shown below:

But why does the Image IO virtual memory grow over time when there are no leaks, and my application just uses 15 MB of live memory?
Is there something I can do to ensure that this IO image memory is freed?
Basically, reading an image from a disk is as follows:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^(void) { NSData *data = [NSData dataWithContentsOfFile:path]; UIImage *image = [UIImage imageWithData:data]; dispatch_async(dispatch_get_main_queue(), ^{ imageView.image = image; }); });
I also tried the following without any significant changes:
- Use
[NSData dataWithContentsOfFile:path options:NSDataReadingUncached error:nil] instead - Move
UIImage *image = [UIImage imageWithData:data]; primarily - Make everything in the main line
Which makes me think that the problem may be elsewhere.
source share