ANR with blocked HeapTaskDaemon thread

前端 未结 3 578
暖寄归人
暖寄归人 2021-02-02 05:13

I get an ANR-error in my Android app. The trace shows only one thread in blocked state (all the others are in state waiting, sleeping, native,..), so it doesn\'t seem to be in d

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 05:56

    Trying to put more information on this issue. So that it can help future user's.

    As you said only one thread in Blocked state, it's clear that it is not a Deadlock. Threads marked as blocked will generally tell you what mutex (lock) they are trying to acquire and the thread ID (tid) of the thread holding that lock.

    In this particular case

    • waiting to lock an unknown object

    Above line tell neither what mutex(lock) it trying to acquire or thread ID holding that lock. (Maybe HeapTaskDaemon thread trying to lock some native object and in that attempt block due to some race condition). So just check with below information and identify the issue in your case and/or put forward an educated guess to prevent it.

    On recent versions of Android, garbage collection(GC) generally runs on a background thread named HeapTaskDaemon. Note that significant amounts of allocation can mean more CPU resources spent on GC.

    Systrace will show you if GC is running frequently, and the Android Memory Profiler can show you where allocations are coming from. If you avoid allocations when you can, especially in tight loops, you shouldn't have a problem.

    check this for more information.

    For more information on ANR and Deadlock's in Android check this link.

    Hope this will help.

提交回复
热议问题