Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak attaching multiple photos in MFMailComposerViewController
    primarykey
    data
    text
    <p>I am trying to attach multiple photos in a <code>MailComposerViewController</code> and I am using <code>ALAssetPickerViewController</code> to pick multiple photos. I have an <code>NSMutableArray</code>, which contains reference of selected assets. I am implementing a <code>for loop</code> which is enumerating over <code>array</code> of selected assets to get <code>NSData</code> of <code>UIImage</code> and <code>UIImage</code> is initialized with <code>CGImageRef</code>. Code is as written below:</p> <pre><code>@autoreleasepool { NSString *emailTitle = @"Test"; NSString *messageBody = @"IOS programming is so fun!"; NSArray *toRecipents = [NSArray arrayWithObjects:@"abc@gmail.com", nil]; MFMailComposeViewController *tempmcvc = nil; tempmcvc = [[MFMailComposeViewController alloc] init]; tempmcvc.mailComposeDelegate = self; [tempmcvc setSubject:emailTitle]; [tempmcvc setMessageBody:messageBody isHTML:YES]; [tempmcvc setToRecipients:toRecipents]; tempmcvc.modalPresentationStyle=UIModalPresentationFullScreen; tempmcvc.navigationBar.barStyle = UIBarStyleBlackOpaque; for (AlAsset *assets in SelectedAssetsarray) { @autoreleasepool { UIImage *attachImagTemp = nil; NSData *myData = nil; CGImageRef iref = [assets.defaultRepresentation fullScreenImage]; NSString *nameOfImgTemp; attachImagTemp = [UIImage imageWithCGImage:iref]; nameOfImgTemp = assets2.defaultRepresentation.filename; myData = UIImageJPEGRepresentation (attachImagTemp, 1.0); [tempmcvc addAttachmentData:myData mimeType:@"image/jpeg" fileName:nameOfImgTemp]; myData = nil; attachImagTemp = nil; iref = nil; nameOfImgTemp = nil; ALAsset *_temp = assets2; _temp = nil; } } } dispatch_async(dispatch_get_main_queue(), ^(void) { [self presentModalViewController:tempmcvc animated:YES] }); </code></pre> <p>Each asset I am attaching hardly is of 2 MB, but memory is constantly decreasing I am unable to release the memory properly; some memory is leaking please help to find the leak. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload