什么是CG栅格数据? [英] What is CG Raster Data?

查看:137
本文介绍了什么是CG栅格数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在我的代码中发现另一个内存泄漏,我似乎无法弄清楚CG Raster Data是什么。在启用自动快照的情况下通过VM Tracker时,CG栅格数据似乎是唯一增加的部分。这些也在不增加分配的情况下稳步增加。

I'm trying to find another memory leak in my code, and I can't seem to figure out what CG Raster Data is. While going through the VM Tracker with automatic snapshots enabled, the CG Raster Data seems to be the only part that increases. These also increase steadily without the allocations increasing.

我不完全确定CG栅格数据是什么,也不确定如何解决它,但此时增加的占用空间最终会导致内存错误和崩溃,所以这不好!我做自己的文本渲染(使用CoreText),所以我认为它与它有关。我也正在加载图片?

I'm not entirely sure what the CG Raster Data is, nor how I would fix it, but at this point the increasing footprint eventually causes a memory error and crash, so it's not good! I do my own text rendering (using CoreText), so I'm thinking that has something to do with it. I also am loading pictures?

下面是足迹图片:

Below is an image of the footprint:

更新:此问题仍然存在,但有趣的是,我可以将其与UIF之中的泄漏关联到称为NSConcreteGlyphGenerator的内容。它似乎只发生在我实际绘制的CoreText方法中的属性字符串上调用boundingRectWithSize:方法时。该行具体是:

UPDATE: This problem still persists, but interestingly enough I can correlate it to a leak within UIFoundations to something called "NSConcreteGlyphGenerator." It seems to happen only when I call a "boundingRectWithSize:" method on an attributed string in the CoreText method that actually draws. The line, specifically, is:

[displayString boundingRectWithSize:CGSizeMake( self.frame.size.width, self.frame.size.height ) options:0 context:nil];

慢慢追踪它......

Slowly tracking it down...

推荐答案

我不知道CG栅格数据可能包含的所有内容,但我确定它包含的一件事是由Core Graphics分配的内存来存储栅格数据,又名位图。

I don't know everything that "CG raster data" might contain, but one thing I know for sure it contains is... memory allocated by Core Graphics to store raster data, aka bitmaps.

具体来说,在我的应用程序中,我使用 CGBitmapContextCreate 创建了两个256x256位图上下文。我传递 NULL 作为 data 参数,以便Core Graphics为我分配位图内存。每像素32位(4字节)的256x256位图需要256 KiB = 64页,每页4 KiB。在Instruments中,我得到两个CG栅格数据块,每块65页。如果我注释掉其中一个位图上下文,我只会在Instruments中获得一个65页的CG栅格数据块。

Specifically, in my app, I create two 256x256 bitmap contexts using CGBitmapContextCreate. I pass NULL as the data parameter, so that Core Graphics allocates the bitmap memory for me. A 256x256 bitmap with 32 bits (4 bytes) per pixel takes 256 KiB = 64 pages of 4 KiB each. In Instruments, I get two "CG raster data" blocks of 65 pages each. If I comment out one of those bitmap contexts, I get just one 65-page "CG raster data" block in Instruments.

另一方面,我也有一个我的应用中的 CATiledLayer CATiledLayer 为我设置了自己的图形上下文,我相信它会使用窗口服务器的共享内存创建这些上下文( springboard < iOS 5上的/ code>,iOS 6上的 backboard 也可以直接访问。我没有看到与这些图形上下文对应的任何CG栅格数据块。

On the other hand, I also have a CATiledLayer in my app. The CATiledLayer sets up its own graphics contexts for me to draw into, and I believe it creates those contexts using shared memory that the window server (springboard on iOS 5, backboard on iOS 6) also directly accesses. I don't see any "CG raster data" blocks corresponding to those graphics contexts.

这篇关于什么是CG栅格数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆