Mobile LLM Troubleshooting.
Diagnose and resolve the most common issues encountered when executing open-source language models on mobile devices: interactive diagnostic decision tree, Android ADB diagnostic commands, ZRAM/RAM Plus debunking, and our 10-issue symptom matrix.
Interactive Diagnostic Decision Tree
Trace your symptom through the decision tree to identify the root cause and execute the verified fix immediately:
App abruptly closes with zero error message when loading a model
Did the screen flash black and drop directly to your home launcher without an ANR dialog?
Android Low Memory Killer (LMK) sent SIGKILL due to physical RAM exhaustion.
When allocating beyond physical RAM headroom, the Linux kernel prioritizes system services and foreground tasks by terminating background and heavy native processes. Native C++ heap allocations by llama.cpp exceeded the kernel minfree watermark.
Switch to a smaller model tier (e.g. 1.5B on 4GB phones, 3B on 6GB/8GB) or switch from Q5/Q8 to Q4_K_M. Reduce context window to 2,048 tokens.
10-Issue Symptom Resolution Matrix
Quick-reference lookup table for the top 10 mobile LLM operational faults:
| Symptom | Root Cause | Verified Fix | Severity |
|---|---|---|---|
| App suddenly closes with no error message when loading a model | Android Low Memory Killer (LMK) sent SIGKILL due to insufficient physical RAM. | Download a smaller model tier (e.g. 1.5B on 4GB phones, 3B on 6GB/8GB) or switch from Q5/Q8 to Q4_K_M. | Critical |
| Token generation starts at 35 tok/s, then slows down to 10 tok/s after 3 minutes | Thermal throttling. Mobile processor junction reached 80°C and kernel throttled CPU clock frequency. | Set thread count to 4 (rather than all 8 cores), remove thick phone case, and avoid charging while generating. | High |
| Model emits infinite repeated phrases (e.g. 'and then and then and then') | Repetition loop in attention sampling. Probability of recent tokens artificially elevated. | Increase Repeat Penalty to 1.15 – 1.20 and set Temperature to 0.7. Avoid Temperature 0.0 for open-ended text. | Medium |
| Error: 'Invalid GGUF header magic' or crash immediately at 0% loading | Corrupted download. Network dropped packets during multi-gigabyte Hugging Face download. | Delete model file from storage, verify unmetered Wi-Fi connection, and re-download cleanly. | High |
| 5–10 second delay before the first token appears (Time-to-First-Token) | Prompt prefill latency. Processor is evaluating a very large input text or document. | Enable memory-mapped I/O (mmap) and trim unnecessary chat history or verbose system instructions. | Low |
| App crashes abruptly during long conversations (Context Window Overflow) | KV cache memory allocation exceeded physical RAM headroom after several chat turns. | Set Context Window to 2,048 tokens in settings and clear older conversation messages to flush KV cache. | Critical |
| Model hallucinates dialogue turns or confuses user and assistant roles | Missing or incorrect Chat Template formatting. Model received raw unformatted text. | Ensure model chat template matches weights: ChatML for Qwen, Llama-3 for Llama 3.2, Gemma for Gemma 2. | Medium |
| Special control tokens visible in output (e.g. '<|im_end|>', '<s>', '<eot_id>') | Tokenizer stop token configuration bleed. Stop tokens were not added to reverse-prompt filter. | Update to latest Local AI build which automatically parses EOS/EOT tokens directly from GGUF metadata. | Low |
| Download halts at 99% or throws 'Storage full / write permission denied' | Device storage partition exhausted or Android scoped storage sandbox permission timeout. | Free at least 6GB of internal flash storage and grant all-files access permission in Android Settings. | High |
| Garbled characters or Chinese symbols generated for English prompts | Tokenizer vocabulary mismatch or extreme temperature setting causing sampling collapse. | Reset Temperature to 0.6 and verify that the downloaded GGUF file matches the official model repository. | Medium |
Android ADB Diagnostic Commands
For developers and technical users: use the Android Debug Bridge (ADB) via USB or Wireless Debugging to inspect kernel memory kills, heap allocation, and thermal sensor registers in real time:
1. Checking Android Low Memory Killer (LMK) Terminations
SIGKILL AuditWhen Android kills Local AI due to RAM pressure, it logs an am_kill event in the kernel buffer:
If OOM_ADJ is 0 or low, Local AI was running in the foreground but total physical memory dropped below minfree thresholds.
2. Inspecting Real-Time App RAM & Native Heap
dumpsys meminfoInspect PSS (Proportional Set Size), Native Heap, and mmap VMA memory mappings allocated by the llama.cpp C++ runtime:
Look at the TOTAL PSS and Native Heap rows. If Total PSS exceeds 75% of your device physical RAM, reduce your model size or context window to avoid LMK eviction.
3. Inspecting Real-Time CPU Frequencies & Thermal Zones
sysfs ThermalRead temperature sensors across CPU junction zones (values are displayed in millidegrees Celsius):
Example reading: 78200 = 78.2°C. When this approaches 80,000 (80°C), you will observe CPU cores downclocking in /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq.
The Myth of Virtual RAM / RAM Plus / ZRAM
Why enabling OEM "RAM Plus", "Memory Extension", or swap partitions completely cripples on-device LLM inference and permanently degrades smartphone flash storage:
- Latency: 50 to 80 nanoseconds (
0.00008 ms) - Bandwidth: 64 GB/s to 85 GB/s memory bus
- Token Speed: 35 – 55 tokens per second
- Endurance: Infinite write cycles (volatile solid-state)
- Latency: 15,000 to 50,000 nanoseconds (
~300× slower) - Bandwidth: 2 GB/s to 4 GB/s (UFS 3.1/4.0 flash)
- Token Speed: Collapses to 0.3 – 1.2 tok/s
- Endurance: Heavy write amplification burns NAND TBW lifecycle
The Mathematical Reason Swap Fails for LLMs:
Standard Android apps (browsers, music players, social media) keep 95% of their memory pages dormant. Swapping cold browser tabs to flash works fine. However, an LLM must read every single parameter weight for every single generated token. When a 4GB model is split into flash swap, the CPU memory controller must page 4GB from flash storage into RAM forty times every second.
The phone experiences catastrophic I/O thrashing, battery drain skyrockets, and write amplification causes permanent premature degradation of your phone internal NAND flash storage. Always disable RAM Plus in Android Settings and rely solely on physical hardware RAM.
Frequently Asked Troubleshooting Questions
Does enabling Android 'RAM Plus' or 'Virtual Memory' (ZRAM) help run larger models?+
Why does my phone get warm when generating responses?+
Can running Local AI permanently damage my smartphone hardware or battery?+
How can I check how much free RAM my Android device has before loading a model?+
Why does loading a model from an external MicroSD card cause stuttering?+
What should I do if a model outputs random gibberish or Asian characters unexpectedly?+
Get Stable Local AI on Android
Equipped with active memory profiling to prevent OOM crashes and safeguard device performance.