运行仪器时模拟内存警告?
有办法做到这一点吗?如果是这样,如何以及可以在模拟器和/或真实设备中运行应用程序时完成吗?
是否有其他方法可以测试仪器中内存警告的响应?
Is there a way to do this? If so, how, and can it be done while running an app in the simulator and/or the real device?
Is there an alternative way to test response to memory warnings in Instruments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,在设备上,出现内存警告的唯一方法实际上是创建内存不足的情况。您可以通过分配一大块内存并在几秒钟后释放它来做到这一点(无论如何不要忘记释放它)。
这可能看起来像黑客,但却是产生低内存条件的最可靠方法。
关于模拟器,您可能知道,在模拟器中运行应用程序时使用 Instruments 检查内存/性能问题并不完全可靠。无论如何,如果您想这样做,可以尝试发送此通知:
(来源)
还请记住,模拟器具有“硬件/模拟内存警告”命令。
On the device, as far as I know, the only way to have a memory warning is actually creating a low memory condition. You can do that by allocating a big chunk of memory and freeing it after a few seconds (don't forget to release it, anyway).
This may appear like a hack, but is the most reliable way of producing a low memory condition.
About the simulator, as you possibly know, using Instruments to check for memory/performance issues while running your app within the simulator is not entirely reliable. Anyway, if you would like to do that, you can try sending this notification:
(Source)
Remember also that the simulator has got the "Hardware/Simulate Memory Warning" command.
您可以在运行 iPhone 模拟器时模拟内存警告,方法是转至菜单并选择:硬件 > 内存警告。模拟内存警告,即使在运行 Instruments 期间也可以随时完成。
You can simulate a memory warning while running the iPhone Simulator by going to the menu and selecting : Hardware > Simulate Memory Warning, which can be done at anytime even during running Instruments .