Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Conversation

@ghost
Copy link

@ghost ghost commented Sep 29, 2014

If setRetainInstance(true) has been set on the fragment or
addToBackStack() was applied to FragmentTransaction, the fragment won't be
destroyed and will keep the reference to its parent view in contentView_
and could lead to memory leak.

This change implements onDestroyView() which cleans the reference.
However, the developer is still responsible for cleaning up the injected
views, because otherwise a (badly implemented) background task may get a
NullPointerException.

If setRetainInstance(true) has been set on the fragment or
addToBackStack() was applied to FragmentTransaction, the fragment won't be
destroyed and will keep the reference to its parent view in contentView_
and could lead to memory leak.

This change implements onDestroyView() which cleans the reference.
However, the developer is still responsible for cleaning up the injected
views, because otherwise a (badly implemented) background task may get a
NullPointerException.
WonderCsabo added a commit that referenced this pull request Sep 29, 2014
Clean contentView_ reference in onDestroyView()
@WonderCsabo WonderCsabo merged commit 7a45e8b into androidannotations:develop Sep 29, 2014
@WonderCsabo
Copy link
Member

Thanks!

@ghost
Copy link
Author

ghost commented Sep 29, 2014

Glad to help!

@WonderCsabo WonderCsabo added this to the 3.2 milestone Sep 29, 2014
@ghost ghost deleted the 933_efragment_ondestroyview2 branch September 29, 2014 17:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant