I'm facing an issue when consecutively running my android test class on an emulated device. I notice that after each run my PC RAM usage steadily increases by about 1.1Gb. This happens until my RAM is full, and then I have to restart my Android Studio and Emulator to run the test class smoothly again.
To investigate I looked at my system monitor. In it, my emulator and android studio maintain roughly constant RAM usage after each test class run.
android studio and emulator RAM usage
However my total RAM usage steadily increases after each test class run 3.2 -> 4.3 -> 5.5 -> 6.7 Gb
On my emulated device I see that my app's maximum memory usage has only been 30mb
I have tried clearing memory after each run using echo 3 > /proc/sys/vm/drop_caches
and this did not affect RAM usage.
I am running Android Studio 2.2.3 on Ubuntu 16.04. The emulated device I use is Android 7.0 API 24 running on Nexus 5, 1Gb RAM, started in terminal using AVD. The test class I'm running contains UI tests using Espresso.
UPDATE: This happens even when running empty espresso tests on an activity with a blank screen (no views). Please find code here