Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Tracking Memory Usage

Myk Melez edited this page Feb 24, 2015 · 2 revisions

Figuring out available memory on a device

adb shell cat /proc/meminfo

  • MemTotal tells you how much device memory is available outside of drivers/kernel.
  • MemFree tells you how much memory is currently available, checking this after booting should give you a rough guesstimate of what our max is.

To simulate what would happen in a low-memory situation you can adb shell kill <pid> each b2g process but b2g, (Nuwa), Homescreen (use b2g-ps to get a b2g process listing). Unfortunately Homescreen just comes back (it can be LMK'd though, so add it's USS to the MemFree total to get a better idea of an ideal MemFree value).

Get an overview of b2g application memory usage

adb shell b2g-procrank (2.x? eng build?) adb shell b2g-ps (1.x? non-eng build?)

Note there are quite a few apps, some of which can get nuked when we need more memory (Homescreen, keyboard, preallocated, usage, etc). The most useful field for your app is probably USS.

Getting a breakdown of memory usage in-app

Use the get_about_memory.py script from the mozilla-b2g/B2G repo.

Example:

git clone https://github.com/mozilla-b2g/B2G.git
cd B2G
tools/get_about_memory.py --minimize

This will write a set of files to about-memory-N. Load the URL it spits out in Firefox to view the memory report.

Measuring on desktop

  1. Start with a clean profile only used for testing j2me.js. You probably want to disable e10s.
  2. Open your j2me.js app and about:memory
  3. Use the app
  4. Measure memory in about:memory
  5. click 'Minimize memory usage' - this will trigger a few rounds of gc/cc
  6. click 'Measure' to get a snapshot of memory usage