静态-ActivityManager-Activity-ClipboardManager

泄露图

问题排查

引用链

源码

case 1:
     ClipboardManager clipboard = (ClipboardManager)
                                  getSystemService(Context.CLIPBOARD_SERVICE);
    /** 替换UBB标签 **/
    String Text = TopicMatcherUtil.ReplaceLabel(commentContent);
    clipboard.setText(String.valueOf(Text));
    UIHelper.makeText(ArticleCommentListActivity.this, "复制成功");
    break;

解决方案

Activity Context 改为 getApplicationContext()

case 1:
     ClipboardManager clipboard = (ClipboardManager)
       this.getApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE);
    /** 替换UBB标签 **/
    String Text = TopicMatcherUtil.ReplaceLabel(commentContent);
    clipboard.setText(String.valueOf(Text));
    UIHelper.makeText(ArticleCommentListActivity.this, "复制成功");
    break;

验证

再次验证,发现无内存泄露,收获 18M 内存


↙↙↙阅读原文可查看相关链接,并与作者交流