GPUimage内存释放
2019-05-21 本文已影响0人
monkey姜啦
1、 上下文释放
GPUImageMovieWriter.m
inputRotation = kGPUImageNoRotation;
_movieWriterContext = [GPUImageContext sharedImageProcessingContext];
// _movieWriterContext = [[GPUImageContext alloc] init];
// [_movieWriterContext useSharegroup:[[[GPUImageContext sharedImageProcessingContext] context] sharegroup]];
GPUImageContext.m ##很重要,会一直增加内存,导致app被kill
- (void)dealloc {
if (_coreVideoTextureCache != NULL) {
CFRelease(_coreVideoTextureCache);
}
}
2、必须要加的代码,内部的buffer回收方法
[[GPUImageContext sharedImageProcessingContext].framebufferCache purgeAllUnassignedFramebuffers];
3、循环引用
__weak typeof(self) weakSelf = self;
__weak typeof(uielement)weakUielement = uielement;
[progressFilter setFrameProcessingCompletionBlock:^(GPUImageOutput *output, CMTime time) {
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf)self = weakSelf;
int index = (int)time.value /time.timescale;
NSLog(@"index:%d",index);
self.sImageView.image = [UIImage imageNamed:@"000"];
self.sImageView.transform = CGAffineTransformMakeRotation(M_PI*index);
[weakUielement updateWithTimestamp:time];
});
}];