How/when is a Handler garbage collected?

后端 未结 3 1195
野的像风
野的像风 2021-02-12 16:15

Inside a class of mine I have the following code:

mHandler = createHandler();

private Handler createHandler() {
    return new Handler() {
        public void h         


        
3条回答
  •  情书的邮戳
    2021-02-12 16:53

    No, stop sending message doesn't make GC work. As the doc points out, it bounds to the thread which creating it. If thread is running, the handler won't be recycled by GC.

    Why do you think this could cause memory leaking? What do you mean by "implicit reference to the enclosing Object"?

提交回复
热议问题