Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 849
Adrian Grigore Avatar asked Jan 03 '12 10:01

Adrian Grigore


People also ask

How do I allocate more memory to my Android emulator?

Go to Tools->Android->AVD Manager , there's something like pencil to edit your AVD click on that, then in the pop-up window click Show Advanced Settings and there you can change the RAM size.

How much RAM do I need for Android emulator?

Android Studio's Emulator Minimum Requirement PC Windows 10 Processor: Dual-core AMD or Intel processor. RAM: 4 GB RAM. Hard Disk: 2 GB. Graphics Card: 1280 x 800 minimum screen resolution with onboard graphics.

How do I increase space on my emulator?

On Android StudioOpen the AVD Manager. Click Edit Icon to edit the AVD. Click Show Advanced settings. Change the Internal Storage, Ram, SD Card size as necessary.

How do I clean my Android emulator?

The easiest way is just to launch the emulator, go to settings -> applications . Then pick the unwanted applications and uninstall them. Alternatively you can do adb -e shell while the emulator is running, find the . apk files in the file system (I think they're under /system/apps) and remove them manually.


2 Answers

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
like image 138
tidbeck Avatar answered Sep 20 '22 17:09

tidbeck


short answer: change orientation if you are using an emulator. if using actual device, change settings by going to settings --> developer options --> don't keep activities.

see my answer to this and this for detailed explanation.

like image 36
numan salati Avatar answered Sep 20 '22 17:09

numan salati