How to reduce the memory consumption in GPUImageGaussianSelectiveBlurFilter effect?

删除回忆录丶 提交于 2019-12-06 07:21:34

If all you're doing is displaying the image to the screen, use -forceProcessingAtSize: on the first filter in your chain. For large input images, that will dramatically reduce their size in memory.

Also, don't load the same image twice, once for your UIImageView and once for your GPUImagePicture. Instead, I recommend removing the UIImageView and displaying an unfiltered version of your image to a GPUImageView by adding a GPUImageView as a parallel target of your GPUImagePicture. That will save a lot of memory right there for a large picture.

Finally, you're going to get crashes with the above code under ARC, because you're not holding on to your GPUImagePicture anywhere. You need to set your GPUImagePicture as an instance variable or property of your class, or it will be deallocated the instant the above method completes. If you're not using ARC, you're leaking memory all over the place in the above (which could be part of your problem).

If you are using old version of GPUImageView then use

[filter prepareForImageCapture]

or if you are using new version then use

[stillImageFilter useNextFrameForImageCapture];

Add this method just above

[imagePic processImage];

which is last line of your code.

Try this, may help you

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!