UIImageJPEGRepresentation received memory warning

前端 未结 3 1391
隐瞒了意图╮
隐瞒了意图╮ 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:27

    in ARC: Just put your code inside small block of @autoreleasepool

     @autoreleasepool {
         NSData *data = UIImageJPEGRepresentation(img, 0.5);
         // something with data
    }
    

提交回复
热议问题