Context leaks in EditText causes out of memory
In android.widget.Editor, Blink runnables can be posted even if
the related TextView is not attached to a window. If a message has
been posted to the Blink message queue and the run method of
the Blink runnable has started executing, the removeCallbacks call
in onDetachFromWindow method is not enough to abort the execution
of the Blink runnable. This results in a memory leak when
the activity is destroyed.
The solution is to cancel the execution of the Blink runnable by
calling the suspendBlink method from onDetachFromWindow method.
Hence the Blink thread will halt, and the referenced context can
be released by GC when the activity is destroyed. Also adding
a corresponding resumeBlink method call in onAttachedToWindow
to start executing the Blink runnable.
Change-Id: Icb26c9c947b3cc1158f7629ae35d7b4e42b80f17
1 file changed