Commit 143f2b7
fix(memory): platform-aware override floor so mid-size models load on high-RAM Android
The user's original bug: a ~3.7GB model refused on a 12GB phone. Root cause: the override
survival floor (1200MB) is calibrated for iOS jetsam, but a 12GB Android phone exposes only
~4.5GB physical availMem, so 4500-3700=800 < 1200 → refused.
Fix (the SAFE version, not the reverted swap-credit): a platform-aware floor. Android backs
the OS and other apps with zram/LMK (foreground app killed last), so the override reserves a
smaller physical margin (KV growth, 700MB) instead of iOS's full jetsam buffer. Crucially this
stays PHYSICAL-based — the dirty model's full footprint is still subtracted from real availMem,
so an oversized dirty model (e.g. 5.2GB LiteRT on ~4.5GB physical → negative) is still REFUSED.
That's the OOM guard my earlier swap-credit fix lacked (it credited swap toward a dirty model
that can't be swapped → loaded → OOM; reverted).
Result: ~3.7GB models load on high-RAM Android (800>700); 5.2GB still refused; iOS unchanged
(800<1200 jetsam floor holds). Tests cover all three. NEEDS on-device verification — [MEM-SM]
logs the real numbers; the 700MB margin may need device tuning.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent ed0cca1 commit 143f2b7
3 files changed
Lines changed: 79 additions & 3 deletions
File tree
- __tests__/unit/services
- src/services
- modelResidency
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
783 | 783 | | |
784 | 784 | | |
785 | 785 | | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
786 | 836 | | |
787 | 837 | | |
788 | 838 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
60 | 81 | | |
61 | 82 | | |
62 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
399 | 404 | | |
400 | | - | |
| 405 | + | |
401 | 406 | | |
402 | 407 | | |
403 | 408 | | |
| |||
0 commit comments