मैं एक तरीका है जिसके एक पाश में कहा जाता है, कि कुछ इस तरह दिखता भीतर परिणाम:जारी renderInContext एक पाश
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIImageView *background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, PAGE_WIDTH, PAGE_HEIGHT)];
background.image = backgroundImg;
for (UIView *view in viewArray)
{
[background addSubview:view];
}
UIGraphicsBeginImageContext(background.frame.size);
[background.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
for (UIView *view in background.subviews)
[view removeFromSuperview];
background.image = nil;
[background release];
[image retain];
[pool drain];
[image autorelease];
return image;
हालांकि
, उपकरण मेमोरी मॉनिटर के अनुसार, स्मृति उपयोग ऊपर और ऊपर जाता है, और लूप के अंत तक कभी नहीं आता है। (यह दुर्घटनाओं।)
अगर मैं की जगह UIGraphicsBeginImageContext साथ
UIImage UIGraphicsEndImageContext को * छवि = someotherimage;
तो मेमोरी स्पाइक नहीं होती है, लेकिन ऑटोरिज़ पूल के कारण, लूप के हर पुनरावृत्ति पर आवंटित और कम हो जाती है। (यह क्रैश नहीं होता है)
और यदि मैं सिर्फ रेंडरइनकॉन्टेक्स्ट लाइन पर टिप्पणी करता हूं तो यह ठीक काम करता है। (क्रैश नहीं होता है)
तो ऐसा लगता है कि रेंडरइनकॉन्टेक्स्ट छवि पर किसी भी तरह पकड़ रहा है - मैं इसे कैसे रिलीज़ कर सकता हूं? या कोई वैकल्पिक सुझाव कृपया :)?
आप एक उद्धारकर्ता हैं! –
बहुत बहुत धन्यवाद .. –