Michaelvilleneuve / react-native-perspective-image-cropper

Perform custom crop, resizing and perspective correction 📐🖼
MIT License
305 stars 128 forks source link

cropping image leads to increasing RAM usage #67

Closed ertan95 closed 5 months ago

ertan95 commented 5 months ago

Every time I take a Photo with react-native-document-scanner and then crop the Image the memory usage of my react native app keeps increasing by 20-30mb. I don't now why it's not releasing the RAM after the crop. Any ideas?

ertan95 commented 5 months ago

Fixed it by modifying CustomCropManager.mm. I added this line of codeCGImageRelease(cgimage); // important to avoid memory leaks

Here's the code snippet from CustomCropManager.mm:


CIContext *context = [CIContext contextWithOptions:nil]; 
CGImageRef cgimage = [context createCGImage:ciImage fromRect:[ciImage extent]];
UIImage *image = [UIImage imageWithCGImage:cgimage];
CGImageRelease(cgimage); // important to avoid memory leaks