【发布时间】:2011-11-03 16:54:12
【问题描述】:
我已经编写了以下代码 sn-p 来截屏:
UIGraphicsBeginImageContext(animationView.frame.size);
[[window layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage* screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但是,UIGraphicsGetImageFromCurrentImageContext 似乎正在泄漏。这是正确的吗?
在 Instruments 中,我无法获得确切的泄漏点。在活动监视器中,我观察到当我切换到执行上述代码的 UI 时,sn-p 内存会增加一些 MB。在此之后,它永远不会减少。 UIGraphicsGetImageFromCurrentImageContext 有内存泄漏吗?我该如何解决?
编辑
仪器分析 Activity Monitor:显示执行这行代码时的内存增加;即使发布截图(UIImage)也不会减少
泄漏和分配,堆快照:不显示任何泄漏或此分配。
【问题讨论】:
标签: ios image cocoa-touch memory memory-leaks