iphone模拟器上模拟内存警告

有三种方法可以实现内存警告。

 

1.模拟器菜单:Hardware-》Simulate Memory Warning

 

2.用程序的方法实现,只需要一句代码:

CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true); 

 

3.这是私有api方法:

SEL memoryWarningSel = @selector(_performMemoryWarning); if ([[UIApplication sharedApplication] respondsToSelector:memoryWarningSel]) { [[UIApplication sharedApplication] performSelector:memoryWarningSel]; }else { NSLog(@"%@",@"Whoops UIApplication no loger responds to -_performMemoryWarning"); }  

 

你可能感兴趣的:(api,null,iPhone)