Reputation: 9192
I write a function to calculate the end index of attributtedString in a rect,
But it seems some memory leak, Please help me to fix it.
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);
thanks in advance.
Upvotes: 3
Views: 696
Reputation: 4425
I did some more investigation on a device and there does seem to be a leak in CoreText, see Memory usage grows with CTFontCreateWithName and CTFramesetterRef
Upvotes: 0
Reputation: 944
There is a special release for CGPathRef objects.
//CFRelease(path);
CGPathRelease(path);
Upvotes: 0
Reputation: 8247
There is no memory leak in the above example. As far as we can see you are releasing everything properly.
Upvotes: 1