Android Studio Simple 'TV' App With Single WebView crashes after long time (profiler shows negative allocated memory?)

拈花ヽ惹草 提交于 2020-06-26 14:52:47

问题


So I have a super simple app with just a WebView that connects to our host page and acts as a 'TV'. After checking for memory leaks, I run this app on my Amazon Fire Stick for an extended period of time, but regardless after around 8-9 hours it crashes without exception on the console. How did I check for memory leaks:

  1. LeakCanary did not detect any leaks.
  2. Watching the memory profiler over time I see that the total memory used always consistently averages 400MB, even at the 8 hour mark.
  3. Comparing to the old version of the program which was worse (it had a lot of unrelated code and was an older project), LeakCanary DID detect leaks on the exact same code, and the profiler did slowly increase the total memory used. This led me to believe that isolating all the necessary code and moving it to a new project solved part of the problem.

Now, the really weird thing is that even though the ALLOCATED memory in the profiler fluctuates, it's DECREASING. In fact to negative numbers. By the 8 hour mark I was seeing it average around -40000. Why's the allocated number negative?

Finally, here's a recurring and suspicious console log I saw right before the crash, hinting it is indeed a memory related crash:

I/Kernel: [126985.795618].(0)[3041:RenderThread]lowmemorykiller: Killing 'VMetricsProcess' (29681), adj 1, score_adj 58,
    [126985.795618]   to free 20124kB on behalf of 'RenderThread' (3041) because
    [126985.795618]   cache 40244kB is below limit 40960kB for oom_score_adj 58
    [126985.795618]   Free memory is 0kB above reserved

Any help would be greatly appreciated as I've been struggling with this bug for so long.

来源:https://stackoverflow.com/questions/62091681/android-studio-simple-tv-app-with-single-webview-crashes-after-long-time-prof

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!