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

EaseExecutor存在内存泄漏 #20

Open
jinanzhuan opened this issue Dec 19, 2022 · 0 comments
Open

EaseExecutor存在内存泄漏 #20

jinanzhuan opened this issue Dec 19, 2022 · 0 comments

Comments

@jinanzhuan
Copy link

内存泄漏信息:
┬───
│ GC Root: Thread object

├─ java.lang.Thread instance
│ Leaking: UNKNOWN
│ Retaining 1.5 MB in 5990 objects
│ Thread name: 'EasyExecutor'
│ ↓ Thread.uncaughtExceptionHandler
│ ~~~~~~~~~~~~~~~~~~~~~~~~
├─ com.haoge.easyandroid.easy.EasyExecutor$TaskWrapper$run$1 instance
│ Leaking: UNKNOWN
│ Retaining 1.5 MB in 5975 objects
│ Anonymous class implementing java.lang.Thread$UncaughtExceptionHandler
│ ↓ EasyExecutor$TaskWrapper$run$1.this$0
│ ~~~~~~
├─ com.haoge.easyandroid.easy.EasyExecutor$TaskWrapper instance
│ Leaking: UNKNOWN
│ Retaining 1.5 MB in 5974 objects
│ ↓ EasyExecutor$TaskWrapper.result
│ ~~~~~~
├─ io.agora.chatdemo.av.DemoCallKitListener$2 instance
│ Leaking: UNKNOWN
│ Retaining 1.5 MB in 5970 objects
│ Anonymous class implementing kotlin.jvm.functions.Function1
│ ↓ DemoCallKitListener$2.val$callback
│ ~~~~~~~~~~~~
├─ io.agora.chat.callkit.ui.EaseCallSingleBaseActivity$3 instance
│ Leaking: UNKNOWN
│ Retaining 1.5 MB in 5969 objects
│ Anonymous class implementing io.agora.chat.callkit.listener.EaseCallKitTokenCallback
│ this$0 instance of io.agora.chatdemo.av.CallSingleBaseActivity with mDestroyed = true
│ ↓ EaseCallSingleBaseActivity$3.this$0
│ ~~~~~~
╰→ io.agora.chatdemo.av.CallSingleBaseActivity instance
​ Leaking: YES (ObjectWatcher was watching this because io.agora.chatdemo.av.CallSingleBaseActivity received
​ Activity#onDestroy() callback and Activity#mDestroyed is true)
​ Retaining 1.5 MB in 5968 objects
​ key = 3c87f3d8-f77b-470e-ac32-9f733bb87aff
​ watchDurationMillis = 10939
​ retainedDurationMillis = 5938
​ mApplication instance of io.agora.chatdemo.DemoApplication
​ mBase instance of androidx.appcompat.view.ContextThemeWrapper

代码中使用如下:
public class DemoCallKitListener implements EaseCallKitListener {

...
private final EasyExecutor executor;
...

public DemoCallKitListener(Context context, UsersManager usersManager) {
    this.mContext = context;
    this.mUsersManager = usersManager;
    executor = EasyExecutor.newBuilder(0)
            .build();
}

@Override
public void onGenerateRTCToken(String userAccount, String channelName, EaseCallKitTokenCallback callback) {
    
    StringBuilder url = buildUrl(userAccount, channelName);

    getRtcToken(url.toString(), agoraUid, callback);
}


private void getRtcToken(String tokenUrl, int agoraUid, EaseCallKitTokenCallback callback) {
    executor.asyncResult(new Function1<Pair<Integer, String>, Unit>() {
        @Override
        public Unit invoke(Pair<Integer, String> response) {
           ...
                                JSONObject object = new JSONObject(responseInfo);
                                String token = object.getString("accessToken");
                                //Set your avatar nickname
                                setEaseCallKitUserInfo(ChatClient.getInstance().getCurrentUser());
                                callback.onSetToken(token, agoraUid);
            ...
            return null;
        }
    })
            .asyncTask(notifier -> {
                try {
                    Pair<Integer, String> response = EMHttpClient.getInstance().sendRequestWithToken(tokenUrl, null, EMHttpClient.GET);
                    return response;
                } catch (ChatException exception) {
                    exception.printStackTrace();
                }
                return null;
            });
}
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