Memory issue in using UIImagePNGRepresentation

此生再无相见时 提交于 2019-11-29 15:48:17

I solve this issue by sending a 4 channels image (RGBA or RGBX) instead of a 3 channels image (RGB).

You can check if there's any chance to change parameters of your image.

The caching is coming from [UIImage imageNamed:], not UIImagePNGRepresentation(). Do this instead:

NSString *imageName = [NSString stringWithFormat:@"image%d.png", i];
NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];

...

I mailed this issue to Apple and they asked me to introduce sleep cycles between every allocation. Add sleep before allocation.

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