Reputation: 41
What are the best practices to avoid out of memory issues in Android fragments?
Do I need to release the memory on fragment destroy?
Upvotes: 1
Views: 303
Reputation: 979
I suggest to use replace
instead of add
, unless you have a specific reason to add fragments.
replace
removes all existing fragment from the layout with the passed resource id, before inserting a new fragment into the layout.
If there are currently no fragments assigned to the layout, it does exactly the same as add
.
Upvotes: 1