skip to content

A tester's Android phone freezes right after login in your app; which adb and dumpsys commands capture and explain what happened?

level: seniorimportance: should knowfreq 40%

answer

  1. frozen, janky or killed
  2. per-service system dumps
  3. two columns that matter in meminfo
  4. traces need root or a bug report
  5. Android 17 caps app memory

basics

~20 s

Capture with adb bugreport, which includes ANR traces, or am monitor while it happens. Then read dumpsys meminfo for leaked Activities, gfxinfo for slow frames and input for stalled dispatch; on Android 17, check whether the memory limiter killed the app.

solid answer

~50 s

First decide whether the app **froze** (an ANR, where the main thread ignores input for 5 seconds), **janked** or was **killed**. To capture, run `adb shell am monitor` while the tester reproduces it, or take `adb bugreport`: ANR traces live in `/data/anr`, and you can pull them only with root, which a retail phone does not give you. Then read specific services, never a bare `dumpsys`. `adb shell dumpsys meminfo com.example.shop` shows `Pss Total` and `Private Dirty`, and an `Activities` count that grows with every login is a leak. `dumpsys gfxinfo <pkg> framestats` shows slow frames, and `dumpsys input` shows which window has focus and whether an ANR is in progress. On Android 17 (API 37) a memory limiter can kill the app: `ApplicationExitInfo` reports `REASON_OTHER` with `MemoryLimiter:AnonSwap`, and `am memory-limiter status` and `ignore` let you confirm it.

code

console · 8 lines
console
$ adb shell am monitor
$ adb shell dumpsys meminfo com.example.shop
$ adb shell dumpsys gfxinfo com.example.shop framestats
$ adb shell dumpsys package com.example.shop | grep userId
    userId=10231
$ adb shell am memory-limiter status
$ adb shell am memory-limiter ignore 10231
$ adb bugreport

go deeper

for a junior

Recall that dumpsys reads system services through adb shell, and that a freeze of about 5 seconds on input is an ANR.

for a middle

Explain which dumpsys service answers which question, and which meminfo columns and object counts actually matter.

for a senior

Show a capture-first workflow on a phone you cannot root, separate freeze from jank from kill, and use the Android 17 memory limiter commands to confirm a cause.

for a principal

Decide what diagnostics the team requires from every field report, such as bug reports and exit reasons, and how memory baselines are set now that Android 17 enforces limits.

## Name the symptom first "It freezes after login" can describe three different failures, and each needs different evidence: - **Frozen**: the screen stops responding. Android raises an **ANR** (Application Not Responding) when the app does not respond to an input event within **5 seconds**, because its main thread is blocked. - **Janky**: the app responds, but frames are slow. - **Killed**: the app disappears, and the next launch starts from scratch. On Android 17 (API 37) a new cause of this is the **app memory limiter**. ## Capture before you analyse 1. **Watch it live.** `adb shell am monitor` starts monitoring for crashes and ANRs while the tester reproduces the problem. Run `adb logcat -b crash` beside it. 2. **Get the traces.** When an ANR happens, Android writes trace files: a single `/data/anr/traces.txt` on older releases, several `/data/anr/anr_*` files on newer ones. `adb pull /data/anr/<file>` works only after `adb root`, which needs an emulator image without the Play Store. 3. **On a retail phone, take a bug report.** `adb bugreport`, or *Take bug report* in Developer options, bundles the logs and the device's diagnostic state, ANR traces included, without root. ## Reading dumpsys `dumpsys` runs on the device and dumps the state of **system services**. A bare `adb shell dumpsys` prints far too much, so name a service. `dumpsys -l` lists the services, `--skip` leaves some out, `-t` changes the 10-second default timeout, and some services take `-h` for their own options. | Command | Answers | |---|---| | `dumpsys meminfo <pkg>` (`-d` for ART detail) | how much RAM the process uses right now, and which objects are alive | | `dumpsys procstats --hours 3` | how memory and run time behaved over the last hours | | `dumpsys gfxinfo <pkg> framestats` | frame timings for jank | | `dumpsys input` | input devices, the focused window, the dispatch queue, and whether an ANR is in progress | | `dumpsys package <pkg>` | package details, including the `userId` line that holds the app's UID | In **meminfo**, the columns that matter are **Pss Total**, the process's share of RAM including a proportional share of shared pages, and **Private Dirty**, memory only this process holds, which is freed only when the process dies. `Heap Alloc` is larger than both, because the process is forked from Zygote and shares its allocations, so it overstates the app's cost. In the `Objects` section: - an **Activities** or **AppContexts** count that grows with each login and logout cycle points to a leaked `Activity`, often held by a static reference or a retained `View`; - **ViewRootImpl** counts root views, one per window, and a growing number points to leaked dialogs or windows. To see what holds the memory, `adb shell am dumpheap com.example.shop /data/local/tmp/login.hprof` writes a heap dump (add `-n` for the native heap), and `adb pull` copies it to your machine. ## Android 17's memory limiter Android 17 (API level 37) sets **app memory limits** based on the device's total RAM. The goal is to stop leaks and other outliers before they destabilize the whole system. When the limiter ends your process, `ApplicationExitInfo.getDescription()` contains `"MemoryLimiter:AnonSwap"` and the exit reason is `REASON_OTHER`. From adb: - `adb shell am memory-limiter status` reports the limits on visible and non-visible processes. - `am memory-limiter ignore <uid>` stops enforcement for every process of that UID, which you can read from `dumpsys package <pkg>`. `none` reverses it, and `all` ignores every app. - `am memory-limiter manual <pid> <MB>` sets a limit on one process, so you can reproduce the kill on purpose. These subcommands have no effect on Android 16 and lower. If the "freeze" disappears while the app is ignored, that points to a memory problem rather than a blocked main thread. ## Common mistakes - Running bare `dumpsys` and drowning in output. - Judging memory by `Heap Alloc` instead of `Pss Total` and `Private Dirty`. - Asking a tester to `adb pull /data/anr` from a phone that cannot be rooted. - Reading `gfxinfo` to explain a freeze. It times frames that were drawn, while an ANR is a main thread that stopped handling input. - Treating every disappearance on Android 17 as a crash, instead of checking the exit reason first. - Taking a single `meminfo` snapshot as proof. Compare several login cycles, or use `procstats` to see memory over hours.

  • How do you prove the Android 17 memory limiter is behind the problem rather than a blocked main thread?
    Read the UID with `dumpsys package <pkg> | grep userId`, run `adb shell am memory-limiter ignore <uid>`, and reproduce. If the problem stops, it is memory. Afterwards, `ApplicationExitInfo` from the earlier sessions shows `REASON_OTHER` with `MemoryLimiter:AnonSwap`, and `am memory-limiter ignore none` restores enforcement.
  • meminfo's Activities count rises with every login. What do you capture next?
    A heap dump of the process after a few cycles: `adb shell am dumpheap com.example.shop /data/local/tmp/login.hprof`, then `adb pull` it and look for what still references the old `Activity`, typically a static field, a retained `View` or a `Drawable`.
  • Why can't the tester just send you `/data/anr` from their phone?
    Pulling ANR traces needs root, and a retail phone or a Play Store emulator image does not provide it. Ask for a bug report instead, either `adb bugreport` or the Take bug report developer option, which bundles the traces with the logs.

  • dumpsys meminfo's Heap Alloc is the app's real RAM cost
  • ANR traces can be pulled from /data/anr on any phone without root
  • A memory-limiter kill shows as REASON_LOW_MEMORY in ApplicationExitInfo
  • am memory-limiter commands also cap apps on Android 16 devices
  • Bare adb shell dumpsys is the fastest way to triage a freeze

Assumes Android 17 (API 37): app memory limits and the am memory-limiter subcommands arrived in it and have no effect on Android 16 and lower.