UIGraphicsGetImageFromCurrentImageContext memory leak with previews

前端 未结 7 937
悲&欢浪女
悲&欢浪女 2020-11-27 19:19

I\'m trying to create previews images of pages in a PDF but I have some problems with the release of memory.

I wrote a simple test algorithm that cycles on the probl

7条回答
  •  独厮守ぢ
    2020-11-27 19:58

    For those who tried all solution above and still has a memory leak, check if you are using a dispatch queue. If so, be sure to set its autoreleaseFrequency to .workItem. Or the autorelease pool you set up inside the will not execute.

    DispatchQueue(label: "imageQueue", qos: .userInitiated, autoreleaseFrequency: .workItem)
    

    Hope it helps, it has bugged me for hours until I finally realize that's DispatchQueue that is holding the block.

提交回复
热议问题