Capture the allocation context
Read the exception message, requested allocation and relevant memory guidance. Record device RAM class, app state, input size and the operation that failed.
A full-resolution image decoded for a small preview can consume far more memory than its compressed file size suggests.
Separate peak usage from leaks
| Pattern | Investigate |
|---|---|
| One large file causes failure | Decode size, buffering and streaming |
| Failure after repeated navigation | Retained references or cache growth |
| Many short-lived allocations | Object churn and collection pressure |
| Managed heap looks modest | Native or graphics allocation |
Use the Memory Profiler and relevant native/graphics tools rather than assuming every allocation belongs to the Java heap.
Reduce the working set
Decode images for their actual display size, process large inputs in bounded chunks where the format allows, and avoid keeping multiple full copies of the same data.
A streaming API still needs review: a downstream conversion that collects the entire stream into memory can erase the benefit.
Bound caches and concurrency
Several individually reasonable tasks can exceed memory limits when they run concurrently. Limit simultaneous heavy operations and release intermediate buffers promptly.
Do not use largeHeap as the default correction. It may change the limit on some devices without fixing scaling, ownership or native pressure.
Test the supported maximum
Use the largest documented input and representative lower-memory devices. Verify that oversized or unsupported input fails clearly before exhausting the process where practical.
APKLint's size and performance tools can help identify packaged assets and review risk areas, but APK size is not runtime heap usage. Keep allocation traces and a reproducible input with the fix, and document realistic limits instead of promising unlimited processing.
Sources and further reading
Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.



