Probe Component for Fast Online OOM Diagnosis in Android Apps
The Probe component continuously monitors Android app memory, automatically captures trimmed HPROF snapshots when usage spikes, and analyzes them either on‑device with the HAHA library or on a server, enabling rapid OOM root‑cause localization, thread/FD tracking, and has lowered the rider app’s crash rate from 2‰ to roughly 0.02‰.
Background: The delivery rider app requires high stability; OOM crashes are critical.
Probe component was built to quickly locate OOM issues online. Its architecture is shown.
OOM causes in Android
OutOfMemoryError originates from /art/runtime/thread.cc. Main causes:
Heap allocation failure – process memory limit or fragmentation.
Thread creation failure – JNI Env allocation or pthread_create.
Relevant source snippets:
void Thread::ThrowOutOfMemoryError(const char* msg) void Heap::ThrowOutOfMemoryError(Thread* self, size_t byte_count, AllocatorType allocator_type) void Thread::CreateNativeThread(JNIEnv* env, jobject java_peer, size_t stack_size, bool is_daemon)Probe’s OOM localization
Probe monitors memory every second; when usage exceeds a threshold it dumps a HPROF snapshot.
Two analysis paths:
Upload full HPROF to server.
Analyze on‑device using the HAHA library.
HA HA analysis extracts Dominator, ShallowSize, RetainSize, etc.
HPROF file trimming
Full HPROF files are hundreds of MB; to reduce upload traffic Probe trims unnecessary primitive array data.
Implementation uses GOT‑table hook (xHook) to intercept open / write, writing a mini‑file while keeping the original.
Thread and FD monitoring
Probe records thread count, stack traces, and FD usage. When thread count or FD count approaches limits, it reports details.
thread name: Thread[...], count: 202 File fdFile = new File("/proc/" + Process.myPid() + "/fd");Results and summary
Probe has reduced the OOM crash rate of the rider app from 2‰ to ~0.02‰. Future work includes better compatibility for Android 7.x and native memory diagnostics.
Authors: Fang Bo, Yi Ran, Yong Gang – Meituan delivery app team.
Recruitment: contact [email protected] for positions.
Meituan Technology Team
Over 10,000 engineers powering China’s leading lifestyle services e‑commerce platform. Supporting hundreds of millions of consumers, millions of merchants across 2,000+ industries. This is the public channel for the tech teams behind Meituan, Dianping, Meituan Waimai, Meituan Select, and related services.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
