【发布时间】:2015-01-23 14:59:26
【问题描述】:
我创建了一个应用程序,用户使用前置摄像头拍照并通过电子邮件发送,该应用程序至少 8 小时不会进入后台;该应用程序显示在办公室中,并且必须始终位于前台。一切都发生在 UIViewController 中。
问题在于 MFMailComposeViewController,特别是它消耗的内存。在 Instruments - Activity Monitor 中有一个 MailCompositionS,它在实际内存使用中不断增加。
我的代码是:
- (void)emailPhoto
{
NSString *emailTitle;
NSString *messageBody;
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
NSData *dataImage = UIImageJPEGRepresentation(photoView.image, 0.4);
[mc addAttachmentData:dataImage mimeType:@"image/jpeg" fileName:@"image.jpg"];
[self presentViewController:mc animated:YES completion:nil];
mc = nil;
dataImage = nil;
}
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:^{
[self backToCamera];
}];
}
我真的不明白可能是什么问题。无论有没有图像附件,MailCompositionS 的内存消耗都会不断增加,并且由于应用程序始终停留在 UIViewController 中并且永远不会进入后台,因此永远不会释放内存。
PS 我没有发现任何泄漏。
【问题讨论】:
标签: ios memory-management mfmailcomposeviewcontroller mfmailcomposer