Fix Memory Leak When Switching Input Methods

Fixes a memory leak when input methods are switched. Uses a variety of methods
to avoid holding a reference to the InputMethodService which created the binders,
which was leaking those InputMethodServices.

See http://code.google.com/p/android/issues/detail?id=6661 for reproduction steps.
This commit is contained in:
Devin Taylor
2010-02-23 13:26:46 -06:00
committed by Garmin Android technology group
parent 27f3de6bac
commit 0c33ed2992
4 changed files with 62 additions and 21 deletions

View File

@ -855,12 +855,26 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
private void finishSession(SessionState sessionState) {
if (sessionState != null && sessionState.session != null) {
try {
sessionState.session.finishSession();
} catch (RemoteException e) {
Log.w(TAG, "Session failed to close due to remote exception", e);
}
}
}
void clearCurMethodLocked() {
if (mCurMethod != null) {
for (ClientState cs : mClients.values()) {
cs.sessionRequested = false;
finishSession(cs.curSession);
cs.curSession = null;
}
finishSession(mEnabledSession);
mEnabledSession = null;
mCurMethod = null;
}
mStatusBar.setIconVisibility(mInputMethodIcon, false);