【发布时间】:2013-06-22 16:54:00
【问题描述】:
我写了一个函数来计算一个矩形中的属性字符串的结束索引,
但似乎有些内存泄漏, 请帮我解决它。
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributtedString);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, rect);
CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(currentIndex, 0), path, NULL);
CFRange frameRange = CTFrameGetVisibleStringRange(frame);
endIndex += frameRange.length;
CFRelease(frame);
CFRelease(path);
CFRelease(framesetter);
提前致谢。
【问题讨论】:
-
在设备上还是在模拟器上?如果在模拟器上,在真机上再次测试;模拟器有时会给出错误的读数。
-
@deanWombourne。我检查了模拟器和活动监视器,它显示实际内存正在增加。当我在设备中检查它时,过程结束,没有任何消息。
-
那么我认为你的问题是它在设备上不起作用 - 稍后我会担心内存使用情况!
-
@deanWombourne。 ya 它在设备中不起作用。我的确切需要是创建一个 NSAttributtedString 看到这个stackoverflow.com/questions/6345780/…
-
@deanWombourne,我发现将它作为 IPA 放在设备上时效果很好。在设备调试时,它仍然显示内存泄漏并导致崩溃
标签: iphone cocoa-touch ipad core-graphics core-text