【问题标题】:A way to send low memory warning to app on iPhone一种向 iPhone 上的应用程序发送内存不足警告的方法
【发布时间】:2012-09-14 13:36:27
【问题描述】:

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

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

【问题讨论】:

    标签: iphone cydia tweak low-memory


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

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

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

    【讨论】:

    • 通知选项是我不知道的那个,谢谢!
    【解决方案2】:

    当您在模拟器上运行应用程序时,您可以这样做:

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

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

    [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
    

    【讨论】:

      猜你喜欢
      • 2012-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多