Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

取消回调后,还是会有连接回调 #198

Open
SJLBenjamin opened this issue Nov 19, 2021 · 0 comments
Open

取消回调后,还是会有连接回调 #198

SJLBenjamin opened this issue Nov 19, 2021 · 0 comments

Comments

@SJLBenjamin
Copy link

SJLBenjamin commented Nov 19, 2021

1.这是我destroy中的取消回调
@OverRide
protected void onDestroy() {
super.onDestroy();
if (mManager != null) {
mManager.unRegisterReceiver(mAllCallBack);
if (mManager.isConnect()) {
mManager.disconnect();
mBtConnect.setText(getString(R.string.begin_connect));
}
}
}
2.回调监听是成员属性,只会有一个,查看了源码,存储此对象是用vector集合,对象能保证唯一性,多次注册相同对象也不会有问题
allCallBack mAllCallBack = new allCallBack();
3.这样操作后,还是会一直连接失败的回调,不知道内存泄露的点在什么地方

后续:查看了源码 源码中会通过hashMap保存manager,外部manager重新打开通道后,上次通道需要关闭,否则还是会造成可达
因为每次连接都会开启一个新的通道,并且内部用hashMap保存了,所以外部直接将mManger=null后,内部还是持有manager-->callBack--->当前界面-->导致无法回收

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant