l uso de la memoria crece con CTFontCreateWithName y CTFramesetterRef
Estoy escribiendo un programa IOS que usa fuentes personalizadas (CTFontManagerRegisterFontsForURL). Cargo la fuente, la agrego como un atributo de cadena, creo un framesetter, luego un marco y lo dibujo en un contexto. Libero todo lo que uso. Los instrumentos no notan una fuga pero:
La memoria utilizada por las aplicaciones crece y no se reduce al usar esta función. El conteo retenido de mi fuente es 2 cuando dejo la función.
Aquí está el código:
CFMutableAttributedStringRef attributedStringRef = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CFAttributedStringBeginEditing(attributedStringRef);
CFAttributedStringReplaceString(attributedStringRef, CFRangeMake(0, 0), (CFStringRef)label.text);
font = CTFontCreateWithName((CFStringRef)label.fontName, label.fontHeight, NULL);
retener conteo de la fuente: 1
CFAttributedStringSetAttribute(attributedStringRef, CFRangeMake(0, label.text.length), kCTFontAttributeName, font);
CFAttributedStringEndEditing(attributedStringRef);
retener conteo de la fuente: 2
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, rect);
CFRelease(font);
retener conteo de la fuente: 1
CTFramesetterRef frameSetter = CTFramesetterCreateWithAttributedString(attributedStringRef);
retener conteo de la fuente: 3
CFRelease(attributedStringRef);
CTFrameRef frame = CTFramesetterCreateFrame(frameSetter,
CFRangeMake(0, 0),
path, NULL);
retener conteo de la fuente: 5
CFRelease(frameSetter);
retener conteo de la fuente: 4
CTFrameDraw(frame, ctx);
CFRelease(frame);
retener conteo de la fuente: 2
CGPathRelease(path);
¿Hay algún tipo de caché? Realmente necesito vaciar la memoria utilizada por esta fuente inmediatamente.
P.S: utilicé CFGetRetainCount para obtener el recuento de retención de la fuente.
Gracias