Ostrzeżenie o pamięci UIImagepickerController IOS 7

Czy ktoś może mi pomóc w tym problemie Jestem trochę nowy w obiektywnym i iOS. Pracowałem nad tym, ale nie wiem, jak rozwiązać problem, Moja aplikacja jest naprawdę prosta, wystarczy uruchomić aparat, robić zdjęcia i wysyłać je pocztą elektroniczną na nasz serwer. Ten kod działał dobrze w iOS6.

Kiedy robię zdjęcia, moja pamięć rośnie wraz z każdym zrzutem ekranu i dostaję komunikat „Received Memory Warning”, a na koniec - Zakończony z powodu ciśnienia pamięci. -

-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{

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

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
    _image = [info
                      objectForKey:UIImagePickerControllerOriginalImage];

   _image = [self fixrotation:_image]; //<----- increased memory when UIImageWriteToSavedPhotosAlbum is uncommented IF is comment it doesn't increased memory but after some pictures I start to get "Received Memory Warning" message until the app Crash.

    if (_newMedia){
       UIImageWriteToSavedPhotosAlbum(_image,
                                       self,@selector(image:finishedSavingWithError:contextInfo:),
                                       nil);
    [self dismissViewControllerAnimated:NO completion:nil];
    [self performSegueWithIdentifier:@"SeleccionadoCameraR" sender:self];


    }else{
        [self performSegueWithIdentifier:@"SeleccionadoCameraR" sender:self];

    }

}

}

- (UIImage *)fixrotation:(UIImage *)image{


if (image.imageOrientation == UIImageOrientationUp) return image;
CGAffineTransform transform = CGAffineTransformIdentity;

switch (image.imageOrientation) {
    case UIImageOrientationDown:
    case UIImageOrientationDownMirrored:
        transform = CGAffineTransformTranslate(transform, image.size.width, image.size.height);
        transform = CGAffineTransformRotate(transform, M_PI);
        break;

    case UIImageOrientationLeft:
    case UIImageOrientationLeftMirrored:
        transform = CGAffineTransformTranslate(transform, image.size.width, 0);
        transform = CGAffineTransformRotate(transform, M_PI_2);
        break;

    case UIImageOrientationRight:
    case UIImageOrientationRightMirrored:
        transform = CGAffineTransformTranslate(transform, 0, image.size.height);
        transform = CGAffineTransformRotate(transform, -M_PI_2);
        break;
    case UIImageOrientationUp:
    case UIImageOrientationUpMirrored:
        break;
}

switch (image.imageOrientation) {
    case UIImageOrientationUpMirrored:
    case UIImageOrientationDownMirrored:
        transform = CGAffineTransformTranslate(transform, image.size.width, 0);
        transform = CGAffineTransformScale(transform, -1, 1);
        break;

    case UIImageOrientationLeftMirrored:
    case UIImageOrientationRightMirrored:
        transform = CGAffineTransformTranslate(transform, image.size.height, 0);
        transform = CGAffineTransformScale(transform, -1, 1);
        break;
    case UIImageOrientationUp:
    case UIImageOrientationDown:
    case UIImageOrientationLeft:
    case UIImageOrientationRight:
        break;
}

// Now we draw the underlying CGImage into a new context, applying the transform
// calculated above.
CGContextRef ctx = CGBitmapContextCreate(NULL, image.size.width, image.size.height,
                                         CGImageGetBitsPerComponent(image.CGImage), 0,
                                         CGImageGetColorSpace(image.CGImage),
                                         CGImageGetBitmapInfo(image.CGImage));


CGContextConcatCTM(ctx, transform);
switch (image.imageOrientation) {
    case UIImageOrientationLeft:
    case UIImageOrientationLeftMirrored:
    case UIImageOrientationRight:
    case UIImageOrientationRightMirrored:
        // Grr...
        CGContextDrawImage(ctx, CGRectMake(0,0,image.size.height,image.size.width), image.CGImage);
        break;

    default:
        CGContextDrawImage(ctx, CGRectMake(0,0,image.size.width,image.size.height), image.CGImage); //when I use instruments it shows that My VM is because of this 
        break;
}

// And now we just create a new UIImage from the drawing context
CGImageRef cgimg = CGBitmapContextCreateImage(ctx);//also this line in Instruments
UIImage *img = [UIImage imageWithCGImage:cgimg];


CGContextRelease(ctx);
CGImageRelease(cgimg);


return img;


 }

prawdopodobnie jest zarządzaniem pamięcią. Będę wdzięczny za twoją pomoc

questionAnswers(3)

yourAnswerToTheQuestion