My app has got a lot of fragments. When I run it in android 5.1.1 it consumes 100-200 Mb, whereas in android studio it shows 30-40 Mb. The problem is that fragments does not get destroyed when i move between them. Is there any way to force close old fragments when I open new ones? I have tried to change behaviour of fragments in onPause and onStop methods, but it was useless
Asked
Active
Viewed 38 times
0
-
You can clear the backstack, http://stackoverflow.com/a/6198068/794088 – petey Oct 19 '15 at 16:45
1 Answers
1
It depends on the number of fragments you have. If you have many fragments, you should use FragmentStatePagerAdapter, which means a fragment will be destroyed once you move to another fragment. If you don't have that many fragments, you could simply use FragmentPagerAdapter, which keeps your fragments in memory.

user3641702
- 393
- 1
- 5
- 18