App stürzt wegen Speicher ab Warnung auf iPad 3
Ich zeichne Linien aufUIImage
und mein Bild ist inUIImageView
. Der erste Zeichenvorgang funktioniert einwandfrei und ich ordne das neue Bild @ zUIImageView
aber wenn ich den Vorgang wiederhole, erhalte ich eine Speicherwarnung und die App stürzt ab:
Terminierung als Reaktion auf die Beendigung des Backboards.
Ich habe meine App profiliert und die CG-Rasterdaten nahmen 273 MB und insgesamt 341 MB Live-Bytes ein. Auch Code in Autorelease-Pool eingewickelt, aber nicht den Erfolg bekommen. Mein Code
UIGraphicsBeginImageContext(imageView.image.size);
[imageView.image drawAtPoint:CGPointMake(0, 0)];
context2=UIGraphicsGetCurrentContext();
for(int i=0; i<kmtaObject.iTotalSize; i++)
{
kmtaGroup=&kmtaObject.KMTA_GROUP_OBJ[i];
//NSLog(@"Group # = %d",i);
for (int j=0; j<kmtaGroup->TotalLines; j++)
{
lineObject=&kmtaGroup->Line_INFO_OBJ[j];
// NSLog(@"Line # = %d",j);
// NSLog(@"*****************");
x0 = lineObject->x0;
y0= lineObject->y0;
x1= lineObject->x1;
y1= lineObject->y1;
color= lineObject->Color;
lineWidth= lineObject->LinkWidth;
lineColor=[self add_colorWithRGBAHexValue:color];
linearColor=lineColor;
// Brush width
CGContextSetLineWidth(context2, lineWidth);
// Line Color
CGContextSetStrokeColorWithColor(context2,[linearColor CGColor]);
CGContextMoveToPoint(context2, x0, y0);
CGContextAddLineToPoint(context2, x1, y1);
CGContextStrokePath(context2);
}
}
newImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageView.image=newImage;