Docs /Troubleshooting & OOM Fixes
DIAGNOSTICS & REPAIR · CRASH PREVENTION

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:

Diagnostic Decision Flowchart
Phase 1Classify Symptom
Phase 2Diagnostic Check
Phase 3Kernel Root Cause
Phase 4Verified Resolution
Memory & LMK

App abruptly closes with zero error message when loading a model

Active Trace Node
Key Diagnostic Verification:

Did the screen flash black and drop directly to your home launcher without an ANR dialog?

Kernel Root Cause Diagnosis:

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.

Verified Resolution:

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.

Execute Diagnostic in ADB:
adb logcat -b events | grep am_kill

10-Issue Symptom Resolution Matrix

Quick-reference lookup table for the top 10 mobile LLM operational faults:

SymptomRoot CauseVerified FixSeverity
App suddenly closes with no error message when loading a modelAndroid 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 minutesThermal 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% loadingCorrupted 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 rolesMissing 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 promptsTokenizer 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 Audit

When Android kills Local AI due to RAM pressure, it logs an am_kill event in the kernel buffer:

adb logcat -b events | grep am_kill
Output format: am_kill: [User, PID, dev.shanaka.localai, OOM_ADJ, "low visual mem"]
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 meminfo

Inspect PSS (Proportional Set Size), Native Heap, and mmap VMA memory mappings allocated by the llama.cpp C++ runtime:

adb shell dumpsys meminfo dev.shanaka.localai

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 Thermal

Read temperature sensors across CPU junction zones (values are displayed in millidegrees Celsius):

adb shell cat /sys/class/thermal/thermal_zone*/temp

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:

Physical LPDDR5X RAM
  • 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)
Virtual RAM / NAND Swap (RAM Plus)
  • 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?+
No! Virtual RAM or ZRAM uses internal flash storage (NAND) as a swap disk. Flash storage is 20 to 50 times slower than physical LPDDR5 RAM. Swapping active LLM tensor weights to flash storage causes massive stuttering, reduces token generation to under 0.5 tokens per second, generates severe battery drain, and wears out your flash memory. Always rely strictly on physical hardware RAM.
Why does my phone get warm when generating responses?+
Unlike browsing the web or streaming video (which use specialized hardware decoders drawing less than 1 watt), local LLM inference utilizes all available ARM Cortex CPU performance cores at near 100% load during generation. Generating a 500-word response takes 10 to 20 seconds of sustained compute, causing the phone metal chassis to naturally dissipate heat.
Can running Local AI permanently damage my smartphone hardware or battery?+
No. Modern smartphone processors (Qualcomm Snapdragon, MediaTek Dimensity, Google Tensor, Samsung Exynos) have hardware-level thermal safeguards. If internal junction temperatures reach safe upper thresholds (typically 80°C to 85°C), the hardware automatically downclocks itself to prevent thermal degradation.
How can I check how much free RAM my Android device has before loading a model?+
Local AI features a built-in hardware profiler directly on the model selection screen that reads /proc/meminfo in real time. It calculates safe available headroom by subtracting active OS services and warns you in red if a selected model exceeds your phone safe allocation threshold.
Why does loading a model from an external MicroSD card cause stuttering?+
MicroSD cards have sequential read speeds between 40 MB/s and 120 MB/s, whereas internal UFS 3.1 and UFS 4.0 storage provides read speeds between 1,800 MB/s and 4,200 MB/s. Loading multi-gigabyte GGUF models from a slow MicroSD card will cause severe initial load lag. Always store active GGUF models in your phone internal storage.
What should I do if a model outputs random gibberish or Asian characters unexpectedly?+
This happens when an incorrect Chat Template is used, causing the model to misinterpret special control tokens as regular text, or when the model context window has been overflowed. Ensure the model settings match its required chat format (e.g. ChatML for Qwen, Llama-3 for Llama) and clear old chat messages to free up context tokens.
SMART RAM SHIELD INCLUDED

Get Stable Local AI on Android

Equipped with active memory profiling to prevent OOM crashes and safeguard device performance.

Get Early Access ↗