2
在我使用UIGraphicsGetImageFromCurrentImageContext()的ipad應用程序中,內存增加得非常高,應用程序崩潰。下面uigraphicsgetimagefromcurrentimagecontext內存提高
UIImage * blendImages(UIImage *background, UIImage *overlay)
{
UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 1024.0,700.0)];
UIImageView* subView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 1024.0,700.0)];
subView.alpha = 1.0;
[imageView addSubview:subView];
imageView.image=background;
subView.image=overlay;
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[subView release];
[imageView release];
return blendedImage;
}
方法blendImages代碼被賦予在循環中被調用時,我給了自動釋放池 我見過問類似的問題,使用UIGraphicsGetImageFromCurrentImageContext()時,與記憶加息,但遺憾的是沒有正確答案,任何幫助,請.. ..
你有沒有得到任何解決方案? – spd 2011-08-26 12:01:50
我有同樣的問題,也許如果我們將UIImage更改爲另一種格式表示形式? – 2011-10-18 20:47:40
[UIGraphicsGetImageFromCurrentImageContext內存泄漏與預覽]的可能重複(http://stackoverflow.com/questions/5121120/uigraphicsgetimagefromcurrentimagecontext-memory-leak-with-previews) – 2016-12-24 05:09:42