BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

GPUImageView Memory Presure iOS 7.1.2 iPhone 4S #1925

Open josete89 opened 9 years ago

josete89 commented 9 years ago

This code cause memory leaks when take 3 or 4 photos :

-(void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.

_stillCamera = [[GPUImageStillCamera alloc] init];
_filter = [[GPUImageGammaFilter alloc] init];

[_filter addTarget:(GPUImageView*)self.view];

_stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
[_stillCamera addTarget:_filter];

[_stillCamera startCameraCapture];

}

-(void)takePhoto{

[_stillCamera capturePhotoAsJPEGProcessedUpToFilter:_filter withCompletionHandler:^(NSData *processedJPEG, NSError *error){
    UIImage *photo = [UIImage imageWithData:processedJPEG];
    NSString *fileName = [NSString stringWithFormat:@"%f.jpeg",[NSDate timeIntervalSinceReferenceDate]];
    [[DiskDispatcher sharedInstance]saveInDisk:processedJPEG withName:fileName completion:^(void){
       // runOnMainQueueWithoutDeadlocking(^{
            _lastPhoto = photo;
            [_imageButton setImage:photo forState:UIControlStateNormal];
        //});
    }];
}];

}

RPallas92 commented 9 years ago

+1

ideacp commented 9 years ago

did you resolve this problem?can you give me some suggest,thank you

josete89 commented 9 years ago

Yes, I resolved releasing the photo and implementing this

SushilSharma12 commented 9 years ago

I tried your code. But it gives me No known instance method for selector purgeAllUnassignedFramebuffers and No known class method for selector sharedFramebufferCache error. How can I do this ?

Ketucalibur commented 9 years ago

I use purgeAllUnassignedFramebuffers, but it seems not release memory...

josete89 commented 9 years ago

You wrapped the method [_stillCamera capturePhotoAsJPEGProcessedUpToFilter:_filter withCompletionHandler] with @autorelasepool ?