CGBitmapContextCreate en el iPhone / iPad

Tengo un método que necesita analizar un montón de imágenes PNG grandes píxel por píxel (las PNG son de 600x600 píxeles cada una). Parece funcionar muy bien en el simulador, pero en el dispositivo (iPad), obtengo un EXC_BAD_ACCESS en alguna función de copia de memoria interna. Parece que el tamaño es el culpable porque si lo pruebo en imágenes más pequeñas, todo parece funcionar. Aquí está la carne relacionada con la memoria del método a continuación.

+ (CGRect) getAlphaBoundsForUImage: (UIImage*) image 
{    
    CGImageRef imageRef = [image CGImage];

NSUInteger width = CGImageGetWidth(imageRef);
NSUInteger height = CGImageGetHeight(imageRef);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

unsigned char *rawData = malloc(height * width * 4);
memset(rawData,0,height * width * 4);

NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * width;
NSUInteger bitsPerComponent = 8;
CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);

CGColorSpaceRelease(colorSpace);

CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
CGContextRelease(context);

/* non-memory related stuff */

free(rawData);

Cuando ejecuto esto en un montón de imágenes, se ejecuta 12 veces y luego falla, mientras que en el simulador no se ejecuta ningún problema. ¿Tienen alguna idea?

Respuestas a la pregunta(7)

Su respuesta a la pregunta