简体   繁体   English

一种向iPhone上的应用程序发送低内存警告的方法

[英]A way to send low memory warning to app on iPhone

I'm looking for some tool/app/tweak that can generate low memory warning on iPhone (jailbroken). 我正在寻找一些可以在iPhone(越狱)上产生低内存警告的工具/应用/调整。 Or, as alternative variant - tweak that simulates high memory usage. 或者,作为替代变体 - 模拟高内存使用量的调整。

I need it to test my app behavior on low memory warning. 我需要它在低内存警告上测试我的应用程序行为。

  • You can test this on the Simulator, thru the " Simulate Memory Warning " menu item (from the " Hardware " menu) 您可以在模拟器上通过“ 模拟内存警告 ”菜单项(从“ 硬件 ”菜单)进行测试
  • On your device, you can call the private method _performMemoryWarning 在您的设备上,您可以调用私有方法_performMemoryWarning

     #if DEBUG [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]; #endif 
  • Another solution is to send the notification manually too: 另一种解决方案是手动发送通知:

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

When you are running the app on simulator, you can do it by: 当您在模拟器上运行应用程序时,您可以通过以下方式执行此操作:

Hardware (on top menu) -> Simulate Memory Warning 硬件(在顶层菜单上) - >模拟内存警告

And for real device you can do it with a private method: 对于真实设备,您可以使用私有方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM