Commit b3826b5
Dmitrii Esin
darwin: fix unsigned underflow in memory meter on ARM64
On macOS with Apple Silicon (16K pages), external_page_count (file-backed
pages) can exceed active_count, causing the unsigned subtraction in
Platform_setMemoryValues to wrap around to ~4 billion pages. This results
in the memory meter displaying ~64 TB of used memory instead of the
actual value.
Use saturatingSub() to clamp the result to zero when the subtraction
would underflow. Intermediate additions are promoted to unsigned long long
to avoid narrowing before the saturating check.
Affects both showCachedMemory=true and showCachedMemory=false paths.1 parent ec95a5f commit b3826b5
1 file changed
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
435 | 442 | | |
436 | 443 | | |
437 | | - | |
438 | | - | |
| 444 | + | |
| 445 | + | |
439 | 446 | | |
440 | | - | |
| 447 | + | |
441 | 448 | | |
442 | | - | |
| 449 | + | |
443 | 450 | | |
444 | 451 | | |
445 | 452 | | |
| |||
0 commit comments