Debugging out-of-memory problems

A common bug to diagnose with Emscripten is where a big game fails due to an out of memory error (OOM) somewhere during load time. By the time about:memory is loaded in a new tab and you have clicked the "Measure" button to diagnose what's happened, the memory usage causing the spike has gone away, making temporary memory spikes difficult to diagnose. This article explains how to debug such problems.

Out-of-memory exceptions from JS

Setting memory.dump_reports_on_oom in about:config to true will cause the browser to automatically write about:memory dumps to a temp file printed to the Browser Console (note: not Web Console) when an OOM crash is encountered. For more information, see bug 969415.

Out-of-memory crashes

In some cases, running out of memory causes the browser to crash.  Ideally, memory.dump_reports_on_oom would generate an about:memory dump, but it does not currently.

Firefox Android

On Firefox Android, an about:memory dump may be triggered from a connect desktop machine with the command:

adb shell am broadcast -a org.mozilla.gecko.MEMORY_DUMP

The location of the dump file will be printed to the Android log (viewed with adb logcat | grep GeckoConsole) and can be retrieved via adb pull. Note: replace "/storage/emulated/0/Download/" in the reported file path with the device's download path (e.g. "/sdcard/download/") when calling adb pull.