Is there an easy way to simulate low memory inside the emulator ? I'm interested to perform resource cleanups similar to this post
Asked
Active
Viewed 1.7k times
3 Answers
25
Invoke ulimit
command from the shell.
ulimit -Sv 10000
This will set current memory limit to 10 000 Kb, so that all apps invoked from this shell afterwards won't be able to access more memory.

P Shved
- 96,026
- 17
- 121
- 165
-
14I get "ulimit: illegal option -v" when I try to perform this command. – Joel McBeth Nov 22 '10 at 16:04
-
3on which shell? Is it `commond prompt` or `telnet`? – Chaitanya K Dec 22 '12 at 10:23
-
I get ulimit: virtual memory: cannot modify limit: Invalid argument – Khaled Annajar Aug 21 '13 at 09:07
-
The "shell" into which the ulimit command has to be entered seems to be the one you can open by using _"adb.exe"_ (Android Debug Bridge). If only one Emulator instance or device is there, then you can just enter _"adb shell"_ in the DosBox (assuming that you are in the directory where adb.exe is located, namely _"sdk/platform-tools"_). – user1364368 Feb 15 '15 at 14:55
-
This is exactly what I was looking for. Thanks so much! (Almost six years later, lol) – JHawkZZ Sep 23 '15 at 17:44
2
If you're just looking to trigger your onTrimMemory callbacks, then this will do the trick:
adb shell am send-trim-memory
e.g. adb shell am send-trim-memory com.example.app MODERATE

Shai Barack
- 677
- 5
- 3
0
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

Dmitriy Tarasov
- 1,949
- 20
- 37
-
-
This does not sends any trim memory events and hence not a true simulation of low memory. – ABS Jun 28 '17 at 22:59