Memory issue in using UIImagePNGRepresentation

前端 未结 3 1185
别跟我提以往
别跟我提以往 2020-12-21 10:31

Hi Guys I found this module to be troublesome. I import more than 100 images from Photolibrary, save them in documents directory with a different name. As expected I had a m

相关标签:
3条回答
  • 2020-12-21 11:12

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

    0 讨论(0)
  • 2020-12-21 11:25

    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.

    0 讨论(0)
  • 2020-12-21 11:25

    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];
    
    ...
    
    0 讨论(0)
提交回复
热议问题