Understanding Resource Overflow: Memory OOM and FD Exhaustion in Android Apps
This article explains how resource overflow such as memory out‑of‑memory (OOM) and file‑descriptor (FD) exhaustion occurs in Android applications, demonstrates how to identify the root causes using MARS‑APM (APMPlus), and provides practical steps to resolve these crashes.
Resource overflow refers to situations where an application exceeds the system resources it can use, most commonly memory leading to Out‑of‑Memory (OOM) errors. Simple Java OOMs can often be traced via stack traces, but native crashes with system‑only stacks require deeper analysis.
java.lang.OutOfMemoryError: Failed to allocate a 3237132 byte allocation with 1612328 free bytes and 1574KB until OOM
When the stack consists entirely of system code, it is difficult to pinpoint the exact cause, but a high virtual memory usage suggests an OOM scenario.
The article then discusses memory limits on 32‑bit and 64‑bit devices, noting that 32‑bit apps on 32‑bit phones cannot reliably use more than ~3 GB, while 64‑bit apps on 64‑bit phones can use up to 4 GB, reducing crash likelihood.
To locate the problem, the MARS‑APM full‑link version (APMPlus) is used. By navigating Native Information → Maps Details , developers can view virtual memory consumption and identify the dominant contributors such as Java runtime, Thread, and Files.
In the example, the Thread entry consumes 2.59 GB, indicating that an excessive number of threads (e.g., doTestThread ) caused the OOM.
The article also covers FD (file descriptor) overflow, where exceeding the OS‑imposed limit (often 1024 on older Android devices) leads to crashes with messages like “Too many open files”.
Signal 6(SIGABRT), Code -1(SI_QUEUE) abort message: 'Could not make wake event fd: Too many open files' #00 pc 000604de /apex/com.android.runtime/lib/bionic/libc.so (abort+165) #01 pc 00005a95 /system/lib/liblog.so (__android_log_assert+176) ...
Using APMPlus, developers can open Native Information → FD Classification to see that the app opened over 30 000 file descriptors, pinpointing the files responsible for the leak.
In summary, both OOM and FD exhaustion are manifestations of insufficient system resources; they cause system calls to fail, and without proper error handling, these failures lead to crashes. The article encourages using APMPlus for comprehensive crash analysis and offers a free 30‑day trial for new users.
ByteDance Terminal Technology
Official account of ByteDance Terminal Technology, sharing technical insights and team updates.
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.