问题
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:
- LeakCanary did not detect any leaks.
- Watching the memory profiler over time I see that the total memory used always consistently averages 400MB, even at the 8 hour mark.
- 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