0

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

1 Answers1

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