I have a problem with fragment when I make an media player app.
I open fragmentB from fragmentA (have addToBackStack) and then back previous fragmentA from fragmentB (using popBackStack). (see more in image). When I popBackStack, all objects and fragmentB has been keep in stack system. Although In fragmentB, onDestroy method is called. So, if I do so again n times, the fragmentB and objects in fragmentB will keep all in stack of system. Finally, when i do again with m times, I got OutOfMemory error.
So, My question is: How to clear all objects and fragmentB after popBackStack?
This is example code i created: https://github.com/sinhpn92/FragmentStackTest