【问题标题】:BButton & CGGradient release - memory leaksBButton & CGGradient 发布 - 内存泄漏
【发布时间】:2013-04-10 02:32:06
【问题描述】:

我正在使用 BButton (https://github.com/jessesquires/BButton) 在 UICollectionView 的单元格中绘制一些漂亮的按钮。当我刷新 UICollectionView 的数据时,我记录了一些内存泄漏(CollectionView 中每个单元格一个泄漏的对象)。我已经使用工具将其追溯到在“BButton.m”中创建的 CGGradient:

gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)newGradientColors, newGradientLocations);
CGColorSpaceRelease(colorSpace);

我知道 CGGradients 应该被释放( CGGradientRelease() ),但是我不确定在哪里释放它,我尝试了几个位置(在绘制按钮之后,在 init 方法中返回之前)但是我仍然遇到同样的问题。

一切都在 IB 中完成,按钮和单元格不是以编程方式创建的。

任何帮助将不胜感激,我快把头发扯掉了!

谢谢

【问题讨论】:

    标签: ios xcode memory-leaks core-graphics


    【解决方案1】:

    我假设您使用的是 ARC。如果你是我认为你的问题是你的 CFArrayRef 没有转移所有权。我找到了this post,所以我不需要重复我的意思。

    【讨论】:

    • 你能发布你的解决方案吗?
    猜你喜欢
    • 1970-01-01
    • 2012-07-18
    • 2014-08-18
    • 2011-10-13
    • 2018-12-30
    • 2014-06-03
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    相关资源
    最近更新 更多