java 你如何在Android模拟器中模拟低内存?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1483047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you simulate low memory in the Android emulator?
提问by Jacques René Mesrine
采纳答案by P Shved
回答by Shai Barack
If you're just looking to trigger your onTrimMemory callbacks, then this will do the trick:
如果你只是想触发你的 onTrimMemory 回调,那么这可以解决问题:
adb shell am send-trim-memory
adb shell am send-trim-memory
e.g. adb shell am send-trim-memory com.example.app MODERATE
例如 adb shell am send-trim-memory com.example.app MODERATE
回答by Dmitriy Tarasov
Another way to do this, if your phone or emulator has application Dev Tools (each emulator has). Open Dev Tools, navigate Development Settings and turn on "Immediatly destroy activities" checkbox. This can help you emulate situation when your activity destroyed as on low memory
另一种方法是,如果您的手机或模拟器具有应用程序开发工具(每个模拟器都有)。打开开发工具,导航开发设置并打开“立即销毁活动”复选框。这可以帮助您模拟活动因内存不足而被破坏的情况

