Android file descriptor leakage debuging

后端 未结 1 1144
孤城傲影
孤城傲影 2021-01-12 20:05

I our company we have a lot of ui-tests which are run on virtual/real devices. After running for some time tests randomly crashing, which I think is the result of file descr

相关标签:
1条回答
  • 2021-01-12 21:01

    I have researched for this question for a while and would like to share what I found:

    1. File descriptor are used in Android at least for:

      • Network sockets (or another type of file)
      • Mapped to memory files
      • Threads - so it was my case. See below why
    2. If you have created a HandlerThread, even if the last link to the HandlerThread instance will disappear thread will still work and consume FileDescriptor

    3. Threads in android can be seen:

      • In "Java heap dump" in Memory Abalyze Tool - so I have seen > 500 threads while running intsrumentation tests - they "eat" all file descriptors
      • Via terminal on android device adb shell ps -t or just ps -t
    0 讨论(0)
提交回复
热议问题