1

我正在寻找一些可以在 iPhone(越狱)上生成内存不足警告的工具/应用程序/调整。或者,作为替代变体 - 模拟高内存使用的调整。

我需要它来测试我的应用程序在内存不足警告时的行为。

4

2 回答 2

3
  • 您可以通过“模拟内存警告”菜单项(来自“硬件”菜单)在模拟器上进行测试
  • 在您的设备上,您可以调用私有方法_performMemoryWarning

    #if DEBUG
    [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
    #endif
    
  • 另一种解决方案是手动发送通知:

    CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true);
    
于 2012-09-14T13:42:05.223 回答
1

当您在模拟器上运行应用程序时,您可以通过以下方式执行此操作:

硬件(在顶部菜单上)-> 模拟内存警告

对于真实设备,您可以使用私有方法:

[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
于 2012-09-14T13:43:32.317 回答