Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory Leaks when calling some CTFunctions in iPhone

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.

like image 802
Naveen Shan Avatar asked Jan 24 '26 14:01

Naveen Shan


1 Answers

There is no memory leak in the above example. As far as we can see you are releasing everything properly.

like image 131
Cocoanetics Avatar answered Jan 26 '26 06:01

Cocoanetics



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!