If you filter in GPUImage, memory leaks.

Asked 2 years ago, Updated 2 years ago, 94 views

In GPUImage, 10 images (960 x 1280) are continuously filtered with sepia.
It consumes approximately 40 MB of memory to run and continues to leak memory.

I have implemented it with the following functions, but I have not substituted the return value for UIImageView.image on the screen.
Simply run the following functions 10 times to leak memory.

I want to release the memory as soon as I finish filtering, but I don't know how to do it.
Please give me some advice.

-(UIImage*)applyFilter:(UIImage*)target{
  GPUImagePicture* imagePicture=[GPUImagePicture alloc] initWithImage:target];
  GPUImageSepiaFilter*sepiaFilter=[GPUImageSepiaFilter alloc] init;
  imagePicture addTarget: sepiaFilter;
  imagePicture processImage;
  UIImage* result = [sepiaFilter imageFromCurrentlyProcessedOutputWithOrientation:target.imageOrientation];
  imagePicture removeAllTargets;
  sepiaFilter removeAllTargets;
  return result;
}

objective-c

2022-09-30 19:34

1 Answers

I checked the operation in the following environment, but there was no memory leak in my environment.
I turned it around with for and stored it in the array to make sure everything is sepia-processed.

Environment
Xcode 6.1.1
iPhone 6
iOS 8.1
GPUImage (0.1.6)

GPUImagePicture* imagePicture=[GPUImagePicture alloc] initWithImage:target];
GPUImageSepiaFilter*sepiaFilter=[GPUImageSepiaFilter alloc] init;
imagePicture addTarget: sepiaFilter;

// It seems that you need to add the following:
sepiaFilter useNextFrameForImageCapture;
imagePicture processImage;

// It seems that the latest imageFromCurrentFramebuffer has been changed.
UIImage* result= [sepiaFilter imageFromCurrentFramebuffer];
imagePicture removeAllTargets;
sepiaFilter removeAllTargets;


2022-09-30 19:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.