UIImageJPEGRepresentation received memory warning

前端 未结 3 1405
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 12:55

I receive a memory warning when using UIImageJPEGRepresentation, is there any way to avoid this? It doesn\'t crash the app but I\'d like to avoid it if possible. It does int

3条回答
  •  旧巷少年郎
    2020-12-03 13:42

    Presented as an answer for formatting and images.

    Use instruments to check for leaks and memory loss due to retained but not leaked memory. The latter is unused memory that is still pointed to. Use Mark Generation (Heapshot) in the Allocations instrument on Instruments.

    For HowTo use Heapshot to find memory creap, see: bbum blog

    Basically the method is to run Instruments allocate tool, take a heapshot, run an iteration of your code and take another heapshot repeating 3 or 4 times. This will indicate memory that is allocated and not released during the iterations.

    To figure out the results disclose to see the individual allocations.

    If you need to see where retains, releases and autoreleases occur for an object use instruments:

    Run in instruments, in Allocations set "Record reference counts" on (For Xcode 5 and lower you have to stop recording to set the option). Cause the app to run, stop recording, drill down and you will be able to see where all retains, releases and autoreleases occurred.

提交回复
热议问题