I have an app that has a separate toolbar for each Fragment. Then the app sets it into Activity with setSupportActionBar method. Apparently this causes Fragment layout to leak after onDestroyView.
What I have tried is
setting
activity.setSupportActionBar(null)which cause issues sinceNavigationlibrary has following sequence of events: new Fragment is created and old calls onDestroyView. So putting the above code in onDestroyView causes thesupportActiobBarto be null.considered having one toolbar which is not easy since requires major refactoring and this is not my personal project.
setting
toolbarto null. Doesn't work causeViewBindingdoesn't allow that.
The questions is - is there any other way to mitigate the memory leak in this case.