Investigating crashes in chrome due to scarcity of available memory

84 views
Skip to first unread message

Usama Naseer

unread,
Aug 17, 2018, 11:12:52 AM8/17/18
to Chromium-dev

I am working on investigating reasons for why chrome crashes especially for old mobile phones. I did some experiments where I opened a website, with js to write to memory indefinitely, on two mobile phones. This is what the results look like:

The timeline is in seconds. At around 90s, the chrome at low-end phone crashed. Total OS RAM usage was >95% for low-end phone and 90-95% for high-end phone.



My intuition was that crash is due to heap being filled or no more memory available to write. The following figure shows chrome memory usage at the same time:


PSS and Private dirty space is higher for low-end phone. This is not the expected behavior and I don't know the reason. The low-end phone is running cyanogen mod and that might be the reason. However, my initial hypothesis proved to be false. Heap size, Heap allocation and Heap free size remains almost constant. I was expecting Heap allocation to reach maximum amount of Heap available and might trigger the crash.


Can anyone help me in understanding the reason behind the crash? Also why does heap memory constant? The free heap size stays at the same state constantly. Is there some sort of threshold in Android that when free heap gets lower that, heap size is increased without consuming any further space from free heap?

Torne (Richard Coles)

unread,
Aug 17, 2018, 11:23:54 AM8/17/18
to usama6...@gmail.com, Chromium-dev
It's hard to say anything without knowing exactly where these numbers came from. Chromium has a number of different allocators and it's not clear what number you are measuring when you say "heap size" - you may not be including *all* the various heaps that exist, for a start.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/3716177b-0463-40a5-85cd-b3b6bbee07f3%40chromium.org.

Usama Naseer

unread,
Aug 17, 2018, 11:26:52 AM8/17/18
to to...@chromium.org, chromi...@chromium.org
The OS RAM usage is from proc/meminfo and Chrome memory usage (PSS, heap etc) is from dumpsys. Doesn't dumpsys capture the entire heap?

Torne (Richard Coles)

unread,
Aug 17, 2018, 11:31:46 AM8/17/18
to Usama Naseer, chromi...@chromium.org
No, it's not guaranteed to. dumpsys's heap statistics refer only to the android libc's heap (memory allocated by calling libc's implementation of malloc), so any other allocators that exist in the process and which obtain memory directly from the kernel with mmap() won't be counted.

PSS being higher on low ram devices is not actually that surprising: on a low ram device, there are fewer processes running overall (background apps being killed more aggressively, etc) and so Chrome's proportional share of the memory that is mapped into all processes (all the system libraries, the memory used by the android zygote, etc) is larger, even though Chrome may be using the exact same amount of memory in total. PSS is not really a valid metric to compare between different use cases on the *same* device, let alone across different devices.

Usama Naseer

unread,
Aug 17, 2018, 12:28:31 PM8/17/18
to to...@chromium.org, chromi...@chromium.org
That's unfortunate. I didn't know that. Any tools that you would recommend to get a complete picture of ram usage?

Thanks for the PSS explanation. That makes sense.

Torne (Richard Coles)

unread,
Aug 23, 2018, 11:53:22 AM8/23/18
to Usama Naseer, chromi...@chromium.org
Chromium has its own memory tracing/logging tools, but I'm not super familiar with how to use them, but https://chromium.googlesource.com/chromium/src/+/lkcr/docs/memory-infra/ might be a good place to start?
Reply all
Reply to author
Forward
0 new messages