ncapdevi / FragNav

An Android library for managing multiple stacks of fragments
1.5k stars 220 forks source link

Memory accumulation issue #100

Closed ghost closed 6 years ago

ghost commented 6 years ago

Switching between tabs in a BottomNavigationView paired with a FragNavController having just 3 fragments is causing the memory used by the app to go up significantly upon each switch. Can I know why? I'm using the method from the documentation provided.

ncapdevi commented 6 years ago

@jishincreo This definitely seems unlikely that it's a specific issue with the library and rather is probably something else that you're doing. There's instances of very complex fragments with five or more deep stacks and not having any issues. Could you try running the sample app in the repo on your phone and seeing if you have the same issue?

ghost commented 6 years ago

@ncapdevi Ran the sample from the repo and it also does accumulate memory when checked with the Android Profiler on AS 3.0. The rate of the memory build up is however low in the sample project when compared to mine as there's only a single button as a view in it. I've got two empty frags and a frag with webView which also does a simple db query with Room.

ncapdevi commented 6 years ago

@jishincreo What would be really helpful would be a comparison between using the traditional backstack vs using the library.

ncapdevi commented 6 years ago

Without further information on this issue, I'm closing it

ntanduc2288 commented 5 years ago

@ncapdevi I'm facing the same issue. I tested on the Sample project and used Android Profiler. Steps:

  1. On BottomTabs Activity, choose Nearby tab (current memory consumption is 25MBs
  2. Click on NearByFragment button 50 times, it means the app will create 50 fragment instances, now the memory is 42MBs
  3. Press the back button to navigate back to the root fragment, it means the current stack just only has one fragment instances.

Observe: The memory is still 42MBs. Look like the memory is not reduced even I call NavigationController.ClearStack()

ntanduc2288 commented 5 years ago

@ncapdevi note that I was using pushFragment method