I have an arc-enabled project which has PersonModel class:
// .h
@interface PersonModel : NSObject
@property (strong, nonatomic) NSString *photoUrl;
@property (strong, nonatomic) UIImage *photo;
@property (strong, nonatomic) NSString *fio;
@end
// .m
@implementation PersonModel
@synthesize photoUrl;
@synthesize photo = _photo;
@synthesize fio;
- (UIImage *)photo
{
if (_photo == nil && self.photoUrl) {
_photo = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.photoUrl]]];
}
return _photo;
}
@end
photo getter is invoked using gcd:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
UIImage *cellImage = model.photo;
});
On line
_photo = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.photoUrl]]];
Instruments shows 100% memory leak. As far as I know arc does not work on threads except main thread. So is there any way of fixing this issue?