0

am using Custom camera for clicking multiple images.now after clicking few images am getting received memory warning and my application isn crashing.Can anyone help me to resolve this.my code showed below

CImage = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];


[arrimages addObject: CImage];





if (aPicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
    custvw.cameraButton.enabled = YES;


}
else
{


    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {

        [self.popoverController dismissPopoverAnimated:true];
        NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

        [self dismissViewControllerAnimated:YES completion:nil];

        if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
        {
            if (picker.sourceType==UIImagePickerControllerSourceTypePhotoLibrary)
            {

                [self.picker dismissViewControllerAnimated:YES completion:nil];

            }

            else
            {





            }


        }
        else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
        {
        }
    }

            else
    {
        [self.picker dismissViewControllerAnimated:YES completion:nil];


    }


    }
rmaddy
  • 314,917
  • 42
  • 532
  • 579
sabir
  • 626
  • 7
  • 19

1 Answers1

0

It's not a good idea to hold the selected images in memory by adding them to an array. These images are in general very memory intensive and can easily fill up the memory.

[arrimages addObject: CImage];

Possible solution:

  • Scale images

Scaling the images after retrieving them from the UIImagePickerControllerDelegate - imagePickerController:didFinishPickingMediaWithInfo: also helps reducing the memory footprint.

How to adjust a image size after using UIImagePickerController take a photo?

  • Save images to disk

Don't keep the images in memory, instead save them to the disk and get them from disk if needed.

iPhone - UIImagePickerController -> save the image to app folder

Community
  • 1
  • 1
charlyatwork
  • 1,187
  • 8
  • 13