ios - iOS drawInRect内存泄漏-ARC

标签 ios objective-c memory automatic-ref-counting drawinrect

我在互联网上进行了搜索,发现很多人和我有同样的问题,但没有解决方案...

如果我有类似NSTimer之类的东西,并且一遍又一遍地循环,并且出于某些原因将代码粘贴在其中,那么我将发生大量内存泄漏,并且大约100次循环后应用程序崩溃。

但是我启用了ARC。

根据仪器,内存问题绝对是win drawInRect

-(void)nstimerTick {

    UIGraphicsBeginImageContextWithOptions(testView.frame.size, NO, 0.0);

    [[testView image] drawInRect:testView.bounds];

    testView.image = UIGraphicsGetImageFromCurrentImageContext();

}

最佳答案

您不会在方法末尾调用 UIGraphicsEndImageContext() 。你应该。

关于ios - iOS drawInRect内存泄漏-ARC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18285803/

相关文章:

c++ - 为什么实例化后什么也没有发生? (C++ 内存分配器实现)

c++ - 使用 malloc 分配比现有内存更多的内存

ios - 在 IOS 中,我们可以在 UITableView 和 UITableView Cell 的背景中设置图像吗?

ios - 如何像 iOS Developer Library 一样设计 UIViewController 视觉布局流程

ios - iPad 方向的响应式设计模板

ios - 如何从 UIGestureRecognizer 获取 UITouch 位置

c - 如何用 block 来定义页面?

ios - 如何比较两个 NSMutableArray?

iphone - 如果 NSMutableArray 已经被属性和合成方法覆盖,我是否需要手动创建它? (附代码)

iphone - 图像应该遵循 iphone 中以前的触摸点?