UIGraphicsGetImageFromCurrentImageContext memory leak with previews

前端 未结 7 962
悲&欢浪女
悲&欢浪女 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:49

    The problem is this:

    UIGraphicsGetImageFromCurrentImageContext()
    

    returns an autoreleased UIImage. The autorelease pool holds on to this image until your code returns control to the runloop, which you do not do for a long time. To solve this problem, you would have to create and drain a fresh autorelease pool on every iteration (or every few iterations) of your while loop.

提交回复
热议问题