fluttercandies / flutter_image_editor

Flutter plugin, support android/ios.Support crop, flip, rotate, color martix, mix image, add text. merge multi images.
Apache License 2.0
407 stars 124 forks source link

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

Closed Allen0505 closed 2 years ago

Allen0505 commented 2 years ago

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();
        }
    });
}
paricleu commented 2 years ago

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