fluttercandies/flutter_image_editor

ios cropping images multiple times in a row may cause a crash

Allen0505 opened this issue · 1 comments

ios cropping images multiple times in a row may cause a crash

There is a memory leak in ios cropping and rotating pictures

add "CGImageRelease(resultCg)" to release memory in FIUIImageHandler.m

- (void)clip:(FIClipOption *)option {
  CGImageRef cg = outImage.CGImage;
  CGRect rect = CGRectMake(option.x, option.y, option.width, option.height);
  CGImageRef resultCg = CGImageCreateWithImageInRect(cg, rect);
  outImage = [UIImage imageWithCGImage:resultCg];
    CGImageRelease(resultCg);  // release memory
}

FIEPlugin.m

- (void)asyncExec:(VoidBlock)block {
    dispatch_async(_queue, ^(){
        @autoreleasepool {
            block();
        }
    });
}

I used your code to create a pr as I needed the fix for my app.
Thank you!