1.1 KiB
1.1 KiB
43. Fix memory leak with Controller's dispose()
Date: 2024-04-05
Status
- Issues:
Context
- Majority, if not all, of TMail's
Controllerare created by extendingBaseController. Everytime a new state arrives,viewState, ofBaseControlleris assigned with new value. This value is never disposed so its reference lives on even if theControlleritself dies that causes memory leak.
Decision
- A new state with name
UIClosedStatewas created for clarification. It extendsBaseUIStatewhich extendsUIState. viewStatewill be assigned toUIClosedState()inside thedispose()method of the memory-leaking controller, so the reference to its previous value is destroyed.- Ideally, this value reasignment of
viewStateshould happen insideBaseController'sdispose(). However, current state of project is not allowed for side effect that can be caused by app wide changes. This can change in the future.
Consequences
SingleEmailController&ComposerController's memory leak problem are resolved.