I am developing an Android app with fragments (=screens) with help of the new Navigation components library.
I have screen [A] and screen [B]. Screen [A] contains items, and screen [B] more details about a specific item. So the user will always switch between screen [A] and [B].
I've discovered that the memory consumption with each opened screen [B] rises and doesn't decrease to previous levels anymore. Even when I force a garbage collection the memory is still way to high. For reference, I get a memory consumption of 100 MB for clicking on approximately 20 items (so it seems like the 20 opened fragments/screens [B] are still hold in memory for some reason).
In Screen [B] I use this line to navigate back to [A].
NavHostFragment.findNavController(this).popBackStack();
So my question is, how do I tell my App to not hold on to these old fragments? Just popping them off the backstack doesn't seem to be enough.