How/when is a Handler garbage collected?

后端 未结 3 1802
闹比i
闹比i 2021-02-12 16:26

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:41

    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"?

提交回复
热议问题