Slide deck
BackSwap Across Five Platforms — Compress First, Spill Later
Turning swap off doesn't cut disk I/O under memory pressure — it shifts the thrashing onto page cache and code, usually worse. Windows, macOS and Android now compress in RAM before touching storage. The toughest tested SSD absorbed 2.4 PB before failing.
Operating Systems · Technical Report
Swap Is Reclaim Fairness, Not Emergency Memory
Turning swap off doesn't cut disk I/O under memory pressure — it shifts the thrashing onto page cache and code, usually worse.
Swap Across Five Platforms1 / 20
What Happened
By the Numbers
- ~40%compressed footprint of a page (Windows 10, 2015)
- 2:1compression ratio the Linux kernel's own docs assume when sizing zram
- 2.4 PBwrites absorbed by the longest-surviving drive in a 2015 SSD endurance test
- 16.4 yrlife of a 600 TBW drive written 100 GB every day
Swap Across Five Platforms2 / 20
What Happened
The Record, Graded
Standing What Confirmed Windows, macOS and Android all compress inactive memory in RAM before writing anything to persistent storage. Confirmed The Windows compression store uses the plain XPRESSformat — not the Huffman-codedXPRESS_HUFFvariant used elsewhere in Windows.Confirmed A Btrfs swapfile has been supported since kernel 5.0, but only on a single-device filesystem, with the file itself uncompressed and unchecksummed. Confirmed — the exception Red Hat Enterprise Linux's own current guide to creating swap names a partition or a file — no compression step at all. Confirmed, device-dependent Which Android OEM's “extended RAM” toggle touches storage, and which only resizes ZRAM. Swap Across Five Platforms3 / 20
Timeline
Turning Points
- 2015A long-run endurance experiment ends: six consumer SSDs are written until they fail; every one outlives its rated endurance, the first only past 700 TB.
- 2015Windows 10 inserts Memory Compression between paging activity and the pagefile, roughly halving page writes to disk.
- 2018The reclaim-fairness argument is published, reframing swap from emergency reserve to routine mechanism.
- 2018PSI merges into the Linux kernel, version 4.20, letting userspace act on stall time before the OOM killer ever runs.
Swap Across Five Platforms4 / 20
Timeline
Turning Points
- 2019Btrfs gains swapfile support in kernel 5.0, with real constraints: the file must sit on a single-device filesystem and go uncompressed.
- 2019macOS's APFS boot layout begins requiring a dedicated, hidden volume to hold swap files, from macOS 10.15 onward.
- 2020Fedora begins shipping ZRAM as the sole, default swap device from release 33, dropping disk-based swap even where hibernation would otherwise be possible.
- 2021→Android OEMs ship “extended RAM” sliders — some resize ZRAM only, others genuinely write to storage.
- 2025An adb-based test of two current flagships settles it: one maker's slider only resizes the compressed tier, the other's genuinely writes to storage.
Swap Across Five Platforms5 / 20
The Argument
Why Swap Still Earns Its Place
File-backed pages can be dropped and re-read; anonymous pages have nowhere to go. Without swap they are simply unreclaimable, so the kernel must take every byte it needs from page cache and program text instead. That is why the strongest argument for swap is not capacity but symmetry: it makes both page classes equally eligible for reclaim, and lets the kernel evict whichever is genuinely colder. The endorsement is institutional, not rhetorical — systemd-oomd's own manual page cites this argument and states swap should be enabled for it to work well, because a swapless system reaches livelock faster and starves the very userspace killer meant to rescue it.
- 2page classes made equally reclaimable
- 4.20+kernel with PSI — pressure visible before the OOM killer
Swap Across Five Platforms6 / 20
The Argument
The Only Three Axes That Matter
Axis The question it asks Why it decides the design Persistent tier Does storage-backed swap exist at all? Some Android implementations only resize ZRAM — there is no second tier to spill into. Hibernation Can the tier hold a suspend-to-disk image? The one hard functional dividing line: a compressed RAM tier is cleared at boot, so it never can. Operator reach How much machinery is exposed? Windows and macOS are effectively automatic; Linux exposes the knobs; Android exposes a slider. Swap Across Five Platforms7 / 20
The Argument
Bottom line
Disabling swap does not avoid disk I/O under memory pressure — it relocates the thrashing from anonymous pages onto page cache and program text, which is usually worse.
Reframe
Sustained swap depth is a sizing signal, not a tuning problem. The fix is more RAM, not more swap.
Swap Across Five Platforms8 / 20
What Others Add
Two Tiers, Five Names
Tier one · in RAM
The Compressed Tier
CPU spent to buy capacity
Tier two · on storage
The Persistent Tier
reached only when compression is exhausted
- 01Residentin RAM
- 02Compressstill in RAM
- 03Spillto disk or UFS
- 04PressurePSI reports stall
- 05Act earlyuserspace OOM
- 06Add RAMthe real fix
Swap Across Five Platforms9 / 20
What Others Add
Platform by Platform
Technology Backend Hibernate Compressed Windows pagefile file on NTFS separate image yes — XPRESS, plainWindows swapfile file, modern apps only no yes — per-app store Linux partition raw partition yes no — pair with zswap Linux swapfile file on the filesystem yes, with offset no — pair with zswap Linux ZRAM block device in RAM never yes — it is the point macOS dynamic swap APFS VM volume yes yes — WKdm / LZ4 Android ZRAM block device in RAM never yes — lz4, zstd or lzo Android extended RAM swapfile on UFS no via ZRAM first Swap Across Five Platforms10 / 20
What Others Add
Where It Holds, Where It Strains
Dimension Holds Strains Hibernation a real partition or file can hold the image a compressed RAM tier is cleared at boot — it can never substitute Flash endurance six consumer SSDs all outlived their ratings, one to 2.4 PB low-tier eMMC and sustained server writes still need care Vendor claims probing the filesystem settles it — some do add a real tier “8 GB + 8 GB = 16 GB” is marketing, not arithmetic Mixing tiers each tier is sound used on its own ZRAM beside disk swap invites LRU inversion Swap Across Five Platforms11 / 20
What Others Add
What the Android Slider Actually Does
Behaviour What changes when you move the slider Cost ZRAM target only No partition and no swap area change — only how much RAM is given to the compressed tier. CPU Real storage swap Free space on the data partition drops by exactly the requested amount, while the ZRAM pool is unchanged. UFS writes Two names, one thing Scheduler and memory-optimisation branding is not swap; only the GB slider is. confusion Below 4 GB RAM Genuinely useful — more background apps survive instead of being killed and reloaded. worth it 12 GB RAM and up Rarely reached in daily use; one hands-on test found phones that add storage swap slightly less responsive than ZRAM-only ones, though not noticeably on a 16 GB handset. responsiveness Swap Across Five Platforms12 / 20
What Others Add
The Endurance Question, Settled
The fear that swap will wear out a drive is the most persistent objection, and it is largely answered. In the best-known long-run experiment six consumer SSDs were written until they died: the first failure came past 700 TB, and the last survivor absorbed 2.4 PB — every drive far exceeding its rated endurance. A drive maker's own endurance guide says so plainly: most manufacturers end the warranty at the rated figure or the time limit, whichever comes first, and consumer drives keep working well beyond their ratings — the rating is a warranty limit, not the point of failure. The arithmetic makes it concrete: a 600 TBW drive written 100 GB every single day lasts over sixteen years, and almost nobody writes that much. Two cases still deserve care — low-tier eMMC in budget phones, and servers under sustained heavy write load, which should be specified by daily-write rating rather than capacity.
Swap Across Five Platforms13 / 20
What Others Add
The Knobs That Actually Exist
Knob What it governs When to move it vm.swappiness (60) How willingly anonymous memory is swapped out relative to reclaiming page cache. Raise it above 100 when swap is faster than the filesystem, as with ZRAM. vm.vfs_cache_pressure (100) How aggressively directory and inode caches are reclaimed against page cache. Rarely. Setting it to zero invites the out-of-memory killer. vm.watermark_scale_factor (10) When background reclaim wakes, and how much it frees once awake. Raise it to keep more memory free on a machine prone to sudden allocation spikes. Swap Across Five Platforms14 / 20
What Others Add
The Knobs That Actually Exist
Knob What it governs When to move it ro.lmk.swap_free_low_percentage (10) The share of free swap, as a percentage, below which lmkd treats the system as swap-starved. Root only, per device — the in-kernel killer was removed once Linux reached 4.12. ro.lmk.psi_complete_stall_ms (700) Milliseconds of complete PSI memory stall — every task blocked at once — that triggers a critical-level kill. Lower thresholds (down to 70ms) ship on low-RAM devices; root only. Swap Across Five Platforms15 / 20
Conclusion
Two Postures, Not Five
Windows · macOS
Leave It Alone
the vendor has already chosen
- Compression and spill are integrated and automatic; there is no tuning to do.
- Disabling the page file costs crash dumps and lowers the commit ceiling — a bad trade.
- On macOS, disabling swap means weakening system protections; the answer is more RAM.
- Watch the pressure indicator, not the swap figure.
Swap Across Five Platforms16 / 20
Conclusion
Two Postures, Not Five
Linux · Android
Choose Deliberately
the defaults are not the decision
- Decide the tier first — hibernation or not — then size it.
- Copy-on-write filesystems impose real constraints on a swap file; follow their own procedure.
- Pair pressure monitoring with a userspace killer, or nothing acts until the machine stalls.
- On a phone, read the slider as a background-app dial with a small cost in responsiveness.
Swap Across Five Platforms17 / 20
Conclusion
Recommendations
- Windows — leave the pagefile system-managed. Disabling it to reclaim a few GB forfeits crash dumps and can destabilise the machine; SSD wear is not a real consideration.
- Linux — pick one tier, not both. ZRAM at half of RAM with zstd for desktops; a real partition or file at least the size of RAM if you hibernate. Avoid running ZRAM beside disk swap wherever you can: cold pages fill the fast tier and push the working set onto disk.
Swap Across Five Platforms18 / 20
Conclusion
Recommendations
- Linux servers — pair PSI with a userspace OOM daemon. Without one, the kernel killer only fires after the machine has already stalled.
- Android — enable it at 4 GB, disable it at 12 GB. Storage is orders of magnitude slower than RAM, and on a flagship the one reported cost is a slight loss of responsiveness.
Swap Across Five Platforms19 / 20
Conclusion
Where it lands
Ask only three questions: do you need hibernation, are you mixing tiers, and is swap depth telling you to buy RAM? Everything else is detail.
Not one convention
“Compress first, spill later” describes Windows, macOS, Android, and a zram-enabled Linux desktop. It does not describe Red Hat Enterprise Linux's own current, documented default, which is a partition or a file with no compression step at all. A server built from that default has no compressed tier to hold ground before storage is touched — which is worth checking before assuming the pattern above applies to it.
Swap Across Five Platforms20 / 20