完全释放CTFont对象?
每当我第一次创建 CTFont 对象时,它都会消耗大约 10 MB 的实际内存。
CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica"), fontSize, NULL);
CFRelease(font);
调用 CFRelease 后,内存消耗不会改变,因此我假设构建并存储了某种字体缓存。 我怎样才能让它消耗更少的内存?
我很担心,因为我的应用程序的其余部分(执行很多操作)仅重 2 MB,而生成文本输出的一小部分占用了 5 倍的空间。 不,我无法使用其他文本输出方法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你不应该担心这个问题。调用
CFRelease
非常好,并且可以了解您可以做什么。 10MB并不算太多。如果您遇到此问题,可能所有 CoreText 应用程序都会遇到此问题。您可以为其提交错误并查看他们的响应。也许它会加载整个字体数据库,然后将其缓存在某个地方以获得更好的性能。我认为那时你无能为力。如果您想了解更多详细信息,请提交错误。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.如果需要缓存字体,请将其放入以 font-name 作为键的字典中。
If you need to cache a font, put it in a dictionary with font-name as a key.