我的iPhone應用程序崩潰後提出了4個低內存警告,儀器顯示沒有內存泄漏,但在內存分配實時字節上升到4.7MB和超過所有字節高達79.0 MB和應用程序崩潰這一點低內存警告後應用程序崩潰
任何幫助,將不勝感激
for (int i = 0; i<3; i++)
{
UIImage *rendered_image;
UIGraphicsBeginImageContextWithOptions(sub_view.bounds.size, NO, 0.0);
[appdelegate.arrimages removeAllObjects];
[appdelegate.arranimations removeAllObjects];
NSString *oldgroup = [[NSString alloc] init];
NSString *currentgroup = [[NSString alloc] init];
for(int i=0; i<[sub_view.data count]; i++)
{
oldgroup = (i>0) ? [sub_view.group objectAtIndex:(i-1)] : [sub_view.group objectAtIndex:i];
currentgroup = [sub_view.group objectAtIndex:i];
/*
IF DIFFERENT GROUP NAME RECEIVED
1-GET NEW INSTANCE OF IMAGE
2-SAVE PREVIOUS IN ARRAY
*/
if (![oldgroup isEqualToString:currentgroup])
{
rendered_image = UIGraphicsGetImageFromCurrentImageContext();
[self SaveImagesOfAnimation:[self compressImageDownToPhoneScreenSize:rendered_image]];
[appdelegate.arranimations addObject:[sub_view.anim objectAtIndex:i]];
UIGraphicsEndImageContext();
UIGraphicsBeginImageContextWithOptions(sub_view.bounds.size, NO, 0.0);
}
id element = [sub_view.data objectAtIndex:i];
color = [sub_view.fillColor objectAtIndex:i];
[color setFill];
[element fill];
[[UIColor blackColor] setStroke];
[element stroke];
}
rendered_image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self SaveImagesOfAnimation:[self compressImageDownToPhoneScreenSize:rendered_image]];
}
儀器還可以顯示您分配的物體種類和確切的堆棧軌跡,因此您應該能夠快速找出它。 – Costique 2012-01-14 07:46:07
檢查此鏈接http://stackoverflow.com/questions/6425043/how-i-can-display-an-alert-when-i-received-memory-warning-level-2-in-iphone-sdk/6425084# 6425084 – 2012-01-14 18:41:28