当前位置: 动力学知识库 > 问答 > 编程问答 >

memory management - Releasing a CTFont object completely?

问题描述:

Whenever I first create a CTFont object it consumes about 10 MB of real memory.

 CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica"), fontSize, NULL);

CFRelease(font);

After calling CFRelease the memory consumption doesn't change so I'm assuming that some sort of font cache is built and stored. How can I make it consume less memory?

I am concerned because the rest of my application which does a lot of things only weighs 2 MB and the little bit that produces text output takes up 5 times as much. And no, I can't use other text output methods.

网友答案:

I don't think you should bother about this issue. Calling CFRelease is pretty-much okay and about what you can do. 10MB is not too much. If you have this problem, probably all CoreText apps have it. You could file a bug for it and see what they respond. Maybe it loads the whole font database that is then cached somewhere for better performance. I think there's nothing you can do then. File a bug if you want to know more details.

网友答案:

If you need to cache a font, put it in a dictionary with font-name as a key.

分享给朋友:
您可能感兴趣的文章:
随机阅读: