What is CG Raster Data?
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.
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.
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.
I had the same issue with CG Raster Data memory increasing by simply pushing and popping a view controller repeatedly. I spent a while thinking it was an issue with some drawing code. I finally tracked it down to a delegate not weakly referencing the view controller that was being pushed and popped, so when I popped the view controller, it wasn't being deallocated. The CG Raster Data happened to be the biggest part of that view controller's footprint, so I mistakenly attributed the problem to that initially, when it was really the view controller itself that wasn't being released (therefore, not releasing its views, some of which had CG Raster Data).
In short: if you're seeing memory leaks with CG Raster Data, look at view controllers that might have views with them, and make sure that they are being released.
This is not much of an answer, but just so someone gets the investigation started...
I think CG Raster Data is new with iOS 6, but was present in iOS 5 as CG Image. I tested on both simulators, and on iOS 5, CG Raster Data wasn't present, but if you compare the total amounts on iOS 6 and iOS 5, CG Image is just about equal to CG Raster Data, and CG Image doesn't show up on iOS 6. So I'm pretty sure they just renamed CG Image to CG Raster Data.
As for what CG Image really is, well I've been trying to figure that out for months. I think it's just view layout related things handled by the system, that you don't really control, because my app doesn't really have any UIImages or CG Images, and my CG Image memory is pretty high, so its probably something to do with Core Animation and view layout.