UIImage memory not deallocating VM: ImageIO_JPEG_DATA?

前端 未结 1 1225
傲寒
傲寒 2021-02-14 17:03

I have multiple collection views on screen at one time that scroll horizontally. They are all filled with images. All of these images are being loaded in the background through

相关标签:
1条回答
  • 2021-02-14 18:06

    I had the same issue in a photo gallery-type app, and ran into the same problem with allocations in the so-called ImageIO_JPEG_DATA category accumulating and remaining "live" forever, causing my app to run out of memory. Oddly, this happenned only on the iPad I was testing on and NOT on the ios simulator (which showed no memory problems).

    Brian's suggestion (below) worked for me. My app was originally using an array, each element of which contained - amongst other things - a UIImage. The images were used in various UIScrollViewControllers.

    When I needed to load an image, if I used

    [UIImage imageWithContentsOfFile:path]

    rather than a direct reference to the UIImage in my array, the memory problem (caused by some inexplicable caching that ImageIO_Malloc was doing) was gone and the ImageIO_JPEG_DATA allocations stopped piling up and got released.

    I would never have come up with this solution in a gazillion years on my own, so thanks to Brian.

    0 讨论(0)
提交回复
热议问题