ibireme / YYKit

A collection of iOS components.
MIT License
13.99k stars 3.69k forks source link

Plus下内存暴涨 #235

Open iOkay opened 8 years ago

iOkay commented 8 years ago

您好!我在做一个聊天框,用到了YYTextLabel控件。在做压力测试的时候发现了个奇怪的问题。在plus下,通过UIGraphicsGetImageFromCurrentImageContext()获得到的图像内存不释放,导致内存暴涨。 然而在其他设备上就不会出现这种情况。 通过instrument查到是-[YYAsyncLayer _displayAsync:]中UIGraphicsGetImageFromCurrentImageContext()生成图片,消耗了大量内存,导致程序崩溃。

请问plus下的图片处理和iphone下的图片处理有什么区别呢?是什么原因到了内存无法释放?

ibireme commented 8 years ago

没有对机型做特殊处理啊? 手头没有 plus 设备来测试。。请问你的情况在模拟器中能复现吗?

iOkay commented 8 years ago

模拟器中也也可以复现,不要选optimize rendering for window scale也可以复现。

nullfy commented 6 years ago

我也遇到同样的情况了@iOkay 大佬有解决嘛

Darwel commented 4 years ago

@iOkay @mumusa UIGraphicsGetImageFromCurrentImageContext()会在CG Raster data 中创建位图数据 UIImage image = UIGraphicsGetImageFromCurrentImageContext(); NSData tmp = UIImagePNGRepresentation(image); UIImage *newImage = [[UIImage alloc] initWithData:tmp];

重新生成一张存在 Image IO 中的图片,会让 CG Raster data里的数据释放掉,可以解决这个问题