I have written this piece of code:
bitmapData = calloc(1, bitmapByteCount );
context = CGBitmapContextCreate (bitmapData,
pixelsWide,
pixelsHigh,
8,
bitmapBytesPerRow,
colorSpace,
kCGImageAlphaOnly);
When I do this, is CGBitmapContext copying my bitmapData, so after these lines i should be writting
free(bitmapData);
If you need
bitmapDatadon’t free it. If you don’t need it, passNULLas a parameter instead and Quartz will allocate memory itself (iOS 4.0 and later).But Quartz doesn’t copy
bitmapData, it does the rendering there. After you releasecontextyou should free that memory.Edit: In one of Apple sample projects, memory is freed, but not immediately: