I have googled for this topic and I found other people encounter same issue.
Here I will give you some inputs from my side.
In my case I have discovered that running tests (we have about 1500 tests) consumes about 5GB at the end of executing.
Our setup is:
- android studio 3.4.2
- jdk 9
- robolectirc 4.2
Obviously somewhere memory leaks.
For each test where we create activity, in @After we call
but it's not enough to prevent dispose some objects allocated during the executing test.
Also, I do some statistics using VisualVM tool and here is output:
As you can see, almost 2.2GB are consumed in first line and (on this preview) robolectric objects allocated about 3.4 GB. Dose anyone know what I need to do in my tests to release that objects?
I assume the robolectric creates some of this objects when create Application object. If it's true then definitely I need to do something with Application instance in @After section. Does this make sense or I'm completely wrong?
Thanks in advance,