Tengo un método que necesita analizar a través de un montón de imágenes PNG grandes píxel por píxel (los PNG son 600x600 píxeles cada uno). 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.CGBitmapContextCreate en el iPhone/iPad
+ (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, que se ejecuta 12 veces y luego dados a cabo, mientras que en el simulador se ejecuta sin problemas. ¿Tienen alguna idea?