-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance issues with lots of Memory Warnings #10
Comments
Yes, you're right, the saving process will cost much memory. I just did a testing and confirmed that the part that drains huge memory is CGSize sizeToSave = CGSizeMake(imageToSave.size.width, imageToSave.size.height);
UIGraphicsBeginImageContextWithOptions(sizeToSave, NO, 0.f);
[imageToSave drawInRect:CGRectMake(0.f, 0.f, sizeToSave.width, sizeToSave.height)];
finalImageToSave = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); This part is for resizing the picture to save. We can scale the image smaller or clip it in square like Instagram App does. However, the demo I offered here still use the original image's size, it's very big cause a high quality picture, Please let me know if you've any question for it, or any suggestion for the performance enhancement. Thanks! B.t.w., this lib's original author is @marintodorov, I just did some modification based on it. If you're interested in the original one, you can refer it HERE. :) |
Hi, I'll close this issue. Please reopen it if you've any question, thx! :) |
Um.. That's weird, I'll take a look at it, thanks! |
And got several leaks, but seems not the reason that cause your memory warning. Well, I'll look deeper when I'm free. :) Created a new issue #12 for these leaks. |
Great, thanks! |
After debugged for a while, I find that this issue exists only on iOS 7.0. Before iOS 7.0, memory will increase when save the photo, but not that much, it's okay. I located the - (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Dismiss image picker view
[self dismissModalViewControllerAnimated:YES];
// Manage the media (photo)
NSString * mediaType = [info objectForKey:UIImagePickerControllerMediaType];
// Handle a still image capture
CFStringRef mediaTypeRef = (__bridge CFStringRef)mediaType;
if (CFStringCompare(mediaTypeRef,
kUTTypeImage,
kCFCompareCaseInsensitive) != kCFCompareEqualTo)
{
CFRelease(mediaTypeRef);
return;
}
CFRelease(mediaTypeRef);
// Manage tasks in background thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage * imageToSave = nil;
UIImage * editedImage = (UIImage *)[info objectForKey:UIImagePickerControllerEditedImage];
if (editedImage) imageToSave = editedImage;
else imageToSave = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];
UIImage * finalImageToSave = imageToSave;
ALAssetsLibrary * assetsLibrary = [[ALAssetsLibrary alloc] init];
[assetsLibrary writeImageToSavedPhotosAlbum:finalImageToSave.CGImage
orientation:(ALAssetOrientation)finalImageToSave.imageOrientation
completionBlock:nil];
});
} This code snippet just save the photo to album after take & use the photo. I've modified the size of I just fired a bug report to Apple (ID: 15050428), hope we can be satisfied with the response. ;) Above are all I can do right now, but for _"getting Memory warning at a rate of about 5 per second"_, um.. actually I cannot reproduce it. I receive the memory warning only on step of saving the photo, but not every time. My environment: |
OK, great, I'll try to look into the problem more myself, thanks! |
@ShadeApps pleasure, I'll do more research on it either :) |
Having downloaded the latest version of the library I'm seeing horrible performance even in the provided Demo App. In my own app I'm getting Memory Warnings regularly. while saving the image. What can be causing them? Attached are 2 profile logs, first of your demo app and second - of my own app implementing your library. Tested on the latest iOS 6 version on iPhone 4S.
The text was updated successfully, but these errors were encountered: