Android Simulator: Easy way to simulate a process restart due to low memory?

Adrian Grigore picture Adrian Grigore · Jan 3, 2012 · Viewed 10.9k times · Source

As I just learned, Android reserves the right to kill a background application's process at any moment in order to recycle RAM. The application is still running and can be resumed nevertheless, but all of my static variables are gone (see this article).

I'd like to simulate my app's behavior in this scenario. What's the easiest way to do this? There certainly must be an easier and more predictable way than writing some additional apps that allocate lots of memory.

Answer

tidbeck picture tidbeck · Jan 3, 2012

Found two similar questions Simulate killing of activity in emulator and Simulate low battery & low memory in Android.

Solutions from those questions:

  • Use adb shell and then kill the process with PID from ps
  • Kill it using DDMS