I'm using CGImageRef and noticed that it uses a lot of memory that doesn't get deallocated.
So I tried experimenting with the following code
- (void)photofromAsset:(ALAsset *)asset completion:(void(^)(NSError *error))completionHandler
ALAssetRepresentation *representation = asset.defaultRepresentation;
UIImageOrientation orientation = (UIImageOrientation)representation.orientation;
CGImageRef fullResolutionImage = representation.fullResolutionImage;
//UIImage *fullImage = [UIImage imageWithCGImage:fullResolutionImage scale:0.0 orientation:orientation];
//[self startUpload:fullImage completion:completionHandler];
}
put some breakpoints and put the first three lines of code in an @autorelease pool.
Then tried removing the @autorelease and called
CGImageRelease(fullResolutionImage);
When I get to UIImageOrientation my app is using less than 30MB
but as soon as I call CGImageRef it gets more than 80MB.
Both memory freeing methods only get me to 50MB, so there's an extra 20MB somewhere.
Those extra 20MB are freed only when the whole method gets completed.
Where are those extra 20MB from?
How can I free them before calling startUpload: ?
Thank you