Rinoy
Rinoy

Reputation: 41

How to avoid out of the memory issues of Fragments in Android?

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

Answers (1)

Mike76
Mike76

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

Related Questions