【问题标题】:iOS drawInRect memory leak - ARCiOS drawInRect 内存泄漏 - ARC
【发布时间】:2013-08-19 14:20:03
【问题描述】:

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

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

但我启用了 ARC。

根据仪器,内存问题肯定是windrawInRect。

-(void)nstimerTick {

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

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

    testView.image = UIGraphicsGetImageFromCurrentImageContext();

}

【问题讨论】:

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


    【解决方案1】:

    您没有在方法结束时调用UIGraphicsEndImageContext()。你应该。

    【讨论】:

    • +1 给你,因为你和我有同样的想法。
    • 哈!这很明显。
    • @KurtRevis,好吧,我觉得很尴尬……哈哈!
    猜你喜欢
    • 2017-10-03
    • 1970-01-01
    • 2012-04-03
    • 2012-01-04
    • 2012-09-14
    • 2012-10-05
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    相关资源
    最近更新 更多