In this guide: 13 sections
- What to do, in order
- On a laptop or desktop, an SSD usually beats a RAM cache
- Three things get called RAM caching
- What to check on a listing page
- The cache you already have
- What a RAM cache is worth
- How much RAM to buy
- Windows: the standby list, SysMain and PrimoCache
- Linux: the page cache and the dirty window
- ZFS: the ARC in brief
- Power cuts: bound the window, because you cannot close it
- Databases and application caches, briefly
- When more RAM is the wrong purchase
Your hard drives already have a RAM cache: Windows, Linux and every other mainstream operating system keep recently read file data in spare memory by default, with nothing to install or switch on. So using RAM to cache hard drives comes down to three things: fit enough memory to hold the data you read again and again, measure that the cache is holding it, and keep any write cache’s window of unsaved data down to seconds. A large Cached figure in Windows Task Manager, or a large buff/cache figure on Linux, is that cache working, not memory wasted. On a laptop or desktop that still starts from a hard drive, an SSD usually does more than any RAM cache, so fit that first. On Windows, the add-on PrimoCache matters mainly for its Defer-Write mode, which tells Windows a write is done before the disk has it, for about as many seconds as you set; a crash or power cut loses whatever had not landed. ZFS keeps its own cache, the ARC, and on current releases lets it grow to all but 1 GiB of memory. And when the data you reuse runs to terabytes, or is read only once, no amount of RAM helps: the money belongs in a flash cache in front of the disks or in cheaper capacity.
What to do, in order
Each step names the reading that justifies it. Skip any step the reading rules out.
- See what the machine starts from. On a laptop or desktop whose system drive is a hard drive, an SSD usually beats a RAM cache, so buy that first and come back. The worked example has the PowerShell lines; on Linux,
lsblk -d -o NAME,ROTAprints 1 beside a spinning disk. - Read the right number. On Windows it is Available in Task Manager; on Linux, the
availablecolumn offree -m. A small free figure beside a large cache figure is what a healthy machine looks like. - Check whether the cache is short. On Windows, watch the counter
\Memory\Long-Term Average Standby Cache Lifetime (s), which Microsoft flags below 1,800 seconds, read beside low Available memory. On Linux, watchfull avg60in/proc/pressure/memoryandmajflt/sfromsar -B. On ZFS, watch the ghost-list hits,mrugandmfug, inzarcstat(arcstatbefore OpenZFS 2.4). Watch for a working week, not a minute. If pressure is flat and nothing would have hit in a bigger cache, more RAM buys nothing. - If it is short, buy memory, not tuning. No setting adds a page. Fill every memory channel before paying for faster modules: on a dual-channel board, two slower modules beat one fast one by half. Which kit for a desktop and whether a laptop can be upgraded take it from there.
- Check the ceiling before ordering. On a laptop that is the maker’s stated maximum, and the memory may be soldered. Board vendors put current consumer DDR5 platforms at 256 GB across four 64 GB modules and most DDR4 desktops at 128 GB, unbuffered modules only; past that you need a server board and registered or load-reduced modules. Check the Windows edition too.
- Keep the write window short. On Windows, use PrimoCache’s Defer-Write only for data you can afford to lose, with a short Latency. On Linux, replace the percentage dirty limits with byte limits sized to a few seconds of the disk’s write speed.
- On a NAS or server, put ECC under a large write cache. A bit flipped in a page that is waiting to be written goes to disk as truth. An everyday desktop does without it.
- Stop buying RAM when the hot data runs to terabytes or is read once. Backups and media archives want capacity at the lowest price per terabyte. A working set too large for any board wants a flash tier under the RAM.
Which case is yours
| Your situation | What helps | What does not |
|---|---|---|
| Laptop or desktop that starts from a hard drive | An SSD for Windows and programs, then more RAM if the counters ask for it | A bigger cache in front of the old drive |
| Windows desktop or workstation on an SSD | Enough RAM that standby lifetime runs to hours; SysMain left on | RAM disk utilities; tools that empty the standby list on a timer |
| Windows, slow writes to a hard drive | PrimoCache Defer-Write with a short Latency, a UPS, and only data you can lose | Treating its SSD tier as crash-safe |
| Linux file server with millions of small files | More RAM; vm.vfs_cache_pressure=50; dirty limits in bytes |
drop_caches from cron |
| ZFS NAS | Let the ARC grow; read its demand and ghost columns; ECC | The 1 GB per TB rule |
| Database server | One layer owns the cache: InnoDB’s buffer pool, or PostgreSQL’s 25 percent plus the page cache | Two full copies of the same pages |
| Backup target or media archive | Capacity at the lowest price per terabyte | Any amount of RAM |
| Hot data in terabytes | A flash tier under the RAM | More DIMMs |
On a laptop or desktop, an SSD usually beats a RAM cache
If Windows starts from a hard drive, an SSD usually does more than any RAM cache. A cache helps only the second read, and the waits people complain about are mostly first reads: starting the machine, opening a program for the first time that day, loading a game level. Those go to the disk however much memory is fitted, because a RAM cache is empty after every restart, and SysMain’s preloading reads from the same disk. An SSD shortens all of them and has nothing to warm up.
The arithmetic further down says the same. With a hard drive at about 10 ms a read, a cache must answer 99 percent of reads to average about 100 us, which an NVMe SSD does with no cache at all, and the SSD still gets the RAM cache on top.
The best-known test dates from 2011. Tom’s Hardware (August 5, 2011) swapped SSDs into hard-drive PCs of 2005 to 2010, saw Windows 7’s start time halved, and concluded that for anyone but a gamer an SSD “will almost certainly facilitate more performance than a RAM upgrade”.
The exception is a machine so short of memory that it pages all day: an SSD makes that hurt less and only more memory stops it, so read the counters and expect it to want both.
Prices make the same case while the shortage lasts:
| eBay US, Buy It Now, November 2, 2026 | Median | Comes to |
|---|---|---|
| Desktop kit, 2 x 16 GB DDR5-5600, new | $25.36 per GB | $812 |
| Desktop kit, 2 x 16 GB DDR4-3200, new | $9.24 per GB | $296 |
| Desktop kit, 2 x 16 GB DDR4-3200, used | $5.78 per GB | $185 |
| 1 TB M.2 NVMe SSD, new | $249 per TB | $249 |
| 1 TB 2.5-inch SATA SSD, new | $240 per TB | $240 |
Those are the medians the DDR5 desktop and DDR4 desktop pages printed for each condition, size and speed, and the drive site’s own for NVMe and SATA SSDs: item prices, before shipping. A new 1 TB SSD cost less than a new DDR4 kit and under a third of a new DDR5 one. Read them again before you pay.
A Windows desktop with a hard drive, worked through
Suppose a Windows 11 desktop with 16 GB of DDR4 as two sticks and one 7,200 rpm hard drive holding Windows, programs, games and photos. It feels slow; Task Manager shows 10 GB Cached, and Resource Monitor under 1 GB Free.
1. Find what Windows starts from. Right-click Start, choose Terminal (Admin), or Windows PowerShell (Admin) on Windows 10, and run:
Get-Partition -DriveLetter C | Get-Disk | Select-Object FriendlyName
Get-PhysicalDisk | Select-Object FriendlyName, MediaType
The first line names the drive holding C:. The second says whether each drive is HDD or SSD; if it says Unspecified, look the name up.
2. Ignore the Cached figure. That 10 GB is the cache working, and most of it is free for the taking.
3. If C: is the hard drive, buy the SSD and stop there for now. Windows, programs and the games you play go on it, and the hard drive keeps the photos. Which SSD to buy for a laptop or desktop says what the machine takes and how to move Windows across. If C: already reads SSD, go on to the next step.
4. Read the counters through a normal working week. Run the lines below while you work. Standby lifetime in hours and Page Reads/sec near zero mean more RAM buys nothing, whatever Task Manager’s percentages say.
5. If they say short, buy a kit, not a tool. Here that means 2 x 16 GB in place of 2 x 8 GB, of the generation the machine has. Which kit for a desktop goes by platform, RAM by processor gives your chip’s memory type, speed and ceiling, and the board’s manual confirms what fits.
6. Leave the rest alone. Keep SysMain on and skip RAM disks and standby-list cleaners; Windows already caches what is on the hard drive. PrimoCache’s Defer-Write earns a look only if you write large files to that drive often and can lose the last few seconds of them.
An older laptop with a hard drive
The order is the same and the gap wider: half a turn of a 5,400 rpm laptop drive takes 5.56 ms, against 4.16 ms at 7,200 rpm. If it has a 2.5-inch bay, a SATA SSD goes in its place, and the SSD guide covers the swap. On November 2, 2026, the drive site’s median 512 GB SATA SSD asked about $135 new and $60 used.
Memory for these machines is the cheap kind: that day a used 2 x 8 GB pair, sold as one listing, came to about $40 at the DDR3 laptop median and $70 at the DDR4 laptop median, before shipping, so a machine that takes them can have both. Whether yours does is the maker’s to say: can you upgrade the RAM in your laptop shows how to spot soldered memory and a free slot in minutes.
Three things get called RAM caching
They fail in different ways, and a safeguard for one does nothing for the others.
| Kind | Examples | What a crash or power cut costs |
|---|---|---|
| Read cache of clean pages | Linux page cache, the Windows standby list, the ZFS ARC | Nothing but a re-read of each page |
| Write cache of dirty pages | Linux dirty pages, the Windows modified page list, PrimoCache Defer-Write | The writes not yet on disk: up to about 35 seconds of them on Linux defaults, about the Latency you set in PrimoCache |
| Explicit RAM store | tmpfs, a RAM disk, Redis with persistence off | Everything on it |
A read cache holds a copy of bytes that already exist on the device, so it is the only one of the three that is free to get wrong. A write cache holds data the disk does not have yet: a successful write(2) only means the kernel has taken custody of your bytes, and until writeback the page in RAM is the authoritative copy. An explicit RAM store has no copy anywhere else, so putting anything there that you cannot regenerate is a durability decision, not a speed tweak.
What to check on a listing page
- The module type matches the machine. A desktop takes unbuffered DIMMs (desktop prices) and a laptop with slots takes SODIMMs (laptop prices), of the generation already in it. The big modules are registered or load-reduced DDR4 and registered DDR5, and they need a memory controller and a socket that accept them. Registered vs unbuffered covers which one a board takes.
- The machine takes it. For a desktop or laptop, RAM by processor gives the chip’s limits and the maker’s manual or spec sheet settles the rest. For a server, look the machine up before buying: the Dell PowerEdge R730, Dell PowerEdge T430, HPE ProLiant DL380 Gen9 and HPE ProLiant MicroServer Gen10 Plus each have a page, and every model is listed under server models. How to check what RAM fits covers reading it off a running machine.
- ECC, if a NAS or server will hold a large write cache or a ZFS pool. Look in ECC DDR4 or ECC DDR5. DDR5’s on-die ECC is not the same thing.
- Enough modules to fill the channels. The bandwidth sum shows why.
- The price per gigabyte, across generations. Compare at RAM prices per gigabyte, and check how that figure has moved on Trends before committing to an older platform’s modules.
- The checks for used modules. Part-number decoding and the eBay buying checks are in buying used RAM on eBay.
The cache you already have
On Windows the Cache Manager maps views of files into ordinary physical pages, which then sit in the system working set, the standby list or the modified page list. Linux calls the same job the page cache, and the kernel describes it in one sentence: “Whenever a file is read, the data is put into the page cache to avoid expensive disk access on the subsequent reads.” Neither has an off switch worth using, so what is left to decide is whether the cache is big enough, and whether it is holding the right data.
Free memory is memory doing nothing
“Cached 12 GB” in Task Manager is not 12 GB spent, for reasons set out in the Windows section. On Linux, free(1) defines free as “Unused memory” and available as an “Estimation of how much memory is available for starting new applications, without swapping”; the second counts reclaimable page cache and the first does not. Current procps-ng computes used as total minus available, which is why old blog arithmetic no longer adds up. A healthy Linux machine shows a small free and a large buff/cache. One caveat: Cached includes tmpfs and shared memory, which cannot be dropped, only swapped, so subtract Shmem before calling the rest reclaimable.
See the effect once
Two timed reads show the size of the effect on your own hardware. On Windows, restart, pick a file of about a gigabyte on the hard drive that nothing has opened since, and run this line twice with your own path; the first read comes from the disk and the second from RAM:
Measure-Command { $null = [IO.File]::ReadAllBytes('D:\bigfile.bin') } | Select-Object TotalSeconds
On Linux:
# cold: discard clean cache, then read
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
time cat bigfile > /dev/null # served by the device
time cat bigfile > /dev/null # served by RAM
Do it once, then leave drop_caches alone. The kernel documentation is blunt: “This file is not a means to control the growth of the various kernel caches (inodes, dentries, pagecache, etc…) These objects are automatically reclaimed by the kernel when memory is needed elsewhere on the system.” The kernel logs who used it, by command and PID, so dmesg | grep drop_caches shows whether a cron job is throwing away a warm cache every hour. The Windows version of the mistake is EmptyStandbyList.exe run every few minutes, as several forum recipes suggest: it frees nothing that was in use and discards a cache Windows must re-read from disk.
What a RAM cache is worth
A RAM hit costs about a thousandth of the latency of the flash underneath it and a hundred-thousandth of the latency of a disk, and neither figure decides anything. The value of a cache is set by its miss rate, not its hit speed, and the miss rate depends on one thing: whether the data you reuse fits.
| Tier | Figure | Where it comes from |
|---|---|---|
| DRAM random load | 81 ns | Measured, DDR4 on Cascade Lake, arXiv:1903.05714 §3.1 |
| Data center NVMe, 4 KB | 130 us at four nines | Solidigm D7-P5520 product brief endnotes |
| Previous-generation NVMe | 230 us at four nines | Solidigm D7-P5510, same brief |
| SATA SSD, 4 KB | 180 to 240 us at five nines | Kingston DC600M datasheet, by capacity |
| 7200 rpm nearline, rotation only | 4.16 ms | Seagate Exos 7E10 datasheet and SAS product manual §4.1 |
Seagate specifies 4.16 ms of average rotational latency for the Exos 7E10 and no average seek time anywhere in the product manual. A random access is rotation plus seek, so the arithmetic below uses 10 ms as a round working number for a random 4 KB read: a modeling assumption, not a specification. To measure your own drive, run fio with --rw=randread --bs=4k --iodepth=1 --direct=1. These are data center parts, but the gaps hold on a desktop, whose 7,200 rpm drive turns at the same speed.
The arithmetic that decides
T_eff = h * T_hit + (1 - h) * T_miss
T_hit = 0.1 us (the DRAM access; a page-cache hit through read(2) also
costs a syscall and a copy, so treat this as a floor)
Backed by NVMe, T_miss = 100 us
h = 0.90 0.090 + 10.000 = 10.09 us
h = 0.95 0.095 + 5.000 = 5.10 us
h = 0.99 0.099 + 1.000 = 1.10 us
h = 0.999 0.100 + 0.100 = 0.20 us
h = 0.9999 0.100 + 0.010 = 0.11 us
Backed by 7200 rpm, T_miss = 10000 us
h = 0.95 0.095 + 500.0 = 500.10 us
h = 0.99 0.099 + 100.0 = 100.10 us
h = 0.999 0.100 + 10.0 = 10.10 us
h = 0.99999 0.100 + 0.1 = 0.20 us
The miss term stops dominating when (1 - h) < T_hit / T_miss:
NVMe at 100 us -> h > 99.9 percent
7200rpm at 10 ms -> h > 99.999 percent
At 90 percent on NVMe the RAM contributes under one percent of the answer; the drive contributes the rest. Going from 95 to 99 percent on NVMe makes the average read 4.6 times faster. Going from a 7200 rpm disk to that NVMe at a fixed 95 percent makes it 98 times faster. On that comparison the storage wins, by a factor of twenty. Within one class the hit ratio dominates, and the returns accelerate rather than flatten: each tenfold cut in the miss rate buys a tenfold cut in average latency, right up to the crossover at the foot of the block. That is why RAM in front of spinning disks has to reach five nines before the disk stops dominating, and why, when the misses go to a disk array, flash that lowers the miss cost is worth more than any plausible amount of DRAM. On one laptop or desktop that flash is simply an SSD. For servers and NAS boxes the drive site covers both routes: NVMe arrays for moving the data onto flash, and NVMe caching for putting flash in front of the disks.
A cache smaller than the working set also does not degrade gently. In the textbook case, a loop that touches N+1 blocks in strict order against an LRU cache that holds N, every block is evicted one access before it is needed again and the hit ratio is zero. Real workloads smooth the edge, but the shape survives, and it is why “another 25 percent of RAM changed nothing” is such a common report.
Where it helps, and where it does not
It helps wherever data is read more than once. On a desktop that means a program started again since the last restart, a photo folder browsed twice, a build or an export run again. Metadata-heavy trees are the clearest case: the dentry and inode caches turn a path lookup into a hash lookup, which is what mail spools, rsync runs and many-small-file build trees live on. Databases with index locality, compile trees and VM hosts whose guests share base images all qualify.
It is nearly worthless where there is no second read. Media streaming, backup targets, large restores and bulk ingest read each block once, and there the cache is not neutral but negative, because each read-once page evicts a page that had reuse. Every serious cache defends against exactly this, and each picked a different defense: the Linux inactive file list, the ARC’s ghost lists, InnoDB’s 3/8 midpoint insertion, PostgreSQL’s 256 kB ring buffer for sequential scans. For a backup target, memory is not the purchase at all; capacity at the lowest price per terabyte is, and every drive ranked by price per terabyte is the place to start.
How much RAM to buy
Enough to hold the working set. Nobody can tell you that number from a ratio: one gigabyte of RAM per terabyte of pool, a quarter of the database, twice the size of the index, each is either the answer to a different question or a guess. Measure, then size the purchase to what the measurement says is missing. RAM by workload in general is covered in how much RAM do you need; this section is about the cache.
Measure on Windows
Windows publishes a better single indicator than Linux does:
Get-Counter -Continuous -SampleInterval 60 `
'\Memory\Long-Term Average Standby Cache Lifetime (s)',
'\Memory\Page Reads/sec',
'\Memory\Available MBytes',
'\Memory\System Cache Resident Bytes',
'\Memory\Modified Page List Bytes'
Microsoft’s troubleshooting guidance for Windows Server (February 7, 2023) lists the first counter with a threshold of 1,800 seconds and does not explain it. Read plainly, a page on the standby list lasts under half an hour on average, which says the working set does not fit. Microsoft gives it for servers, so on a desktop treat it as a guide, read through normal use and not just after a restart. Microsoft lists it beside Available memory and the system cache, and sends you to RAMMap when Available MBytes is low and the system cache holds a large share of memory. Page Reads/sec is the other half. It counts disk reads that resolve hard page faults, and Microsoft’s counter reference (June 29, 2006) includes faults in the file system cache, so first reads raise it too: ignore a burst as something new opens. Sustained through normal work, it means more memory would help. Lifetime in hours with healthy Available memory means more RAM buys nothing.
Measure on Linux
# Linux: is the machine genuinely short of memory?
grep -E '^(some|full)' /proc/pressure/memory # full avg60 > 0 means stalls
sar -B 1 5 # majflt/s, pgscan, %vmeff
vmstat 1 5 # si/so should be 0
/proc/pressure/memory reports full when “all non-idle tasks are stalled”, averaged over 10, 60 and 300 seconds. Alarm on full avg60, never on free memory: a healthy cache-heavy machine looks 95 percent used and has a flat pressure line. In sar -B, a low %vmeff (pgsteal over pgscan) under load means the kernel is scanning hard and finding little, which is a real shortage rather than a full cache.
For the shortfall itself, the cachestat(2) system call, in Linux since 6.5, returns nr_recently_evicted for a file range: pages that were cached and were evicted recently enough that reading them again would count as a refault. That is the shortfall you are paying for, in pages. On ZFS, mrug and mfug report the same thing directly, as the ZFS section explains.
The Active(file) and Inactive(file) lines in /proc/meminfo are a free reading, though the proc_meminfo(5) man page still says “[To be documented.]” against both. By behavior, a file page lands on the inactive list when first read and is promoted on a second reference, so a large inactive share means most of the cache is single-read streaming data, and a large active share means a real hot set is resident. On a kernel running MGLRU (check /sys/kernel/mm/lru_gen/enabled) the two lines are only accounting, not the reclaim algorithm, so read them as a rough guide.
Four starting points, to be measured rather than obeyed
Desktop or laptop: 16 GB for office work, 32 GB for games, photos or builds, the targets in how much RAM do you need. Past what the programs use, the rest is cache earning its keep on the second read, not the first. If standby lifetime runs to hours and Page Reads/sec stays near zero for a working week, or on Linux full avg60 and vmstat’s si and so stay at zero, more memory buys nothing and the money belongs on the drive.
Home server or NAS: 8 GB for files alone, 16 GB to 32 GB with apps, 64 GB with virtual machines. The driver is usually metadata rather than data: directory trees and inodes, which Linux accounts in SReclaimable rather than Cached. On ZFS, size by ghost hits, not by pool capacity. What TrueNAS, Proxmox, Unraid and Synology each ask for, and what their apps and guests add, is in how much RAM for a NAS or homelab.
Database server: the indexes and the hot tables, plus a copy. PostgreSQL relies on the operating system’s cache as well as its own, while InnoDB keeps the only copy; decide which layer owns it, as the databases section sets out, then buy for that.
Virtualization host: the sum of the guests’ measured working sets, not the sum of their configured RAM. Guests size their caches to the memory they can see, so ten 32 GB guests will fill most of 320 GB with page cache that looks in use from the host. When the host reclaims, ten cache-miss storms land on the same array together: overcommit turns independent caches into a correlated failure. Use cache=none on guest disks, so a block is not held in the host’s page cache and the guest’s at once.
The platform ceiling
A laptop’s ceiling is the maker’s stated maximum, and it may have no slot at all. On a desktop, past a certain capacity the answer stops being a bigger kit and becomes a different machine. A consumer board gives up to four slots across two channels and takes unbuffered modules only, because electrical load, not address space, is the wall.
Consumer board, 4 slots, UDIMM only
4 x 64 GB = 256 GB (board- and BIOS-dependent support)
Server socket, 12 channels, 1 DIMM per channel
12 x 64 GB RDIMM = 768 GB
12 x 128 GB LRDIMM/3DS = 1.5 TB
Both groups are arithmetic on parts that exist rather than vendor population tables: 64 GB unbuffered modules are sold, but board and BIOS support for them is uneven, and the twelve-channel rows assume a twelve-channel socket such as EPYC 9004 or EPYC 9005. Registered vs unbuffered covers what each type buffers and which a board takes, and server memory capacity limits has the per-platform maxima. The operating system has a ceiling as well: Windows 11 Home stops at 128 GB, Pro at 2 TB, and Pro for Workstations and Enterprise at 6 TB.
Bandwidth: fill the channels first
Per channel: GB/s = MT/s x 8 bytes per transfer (64-bit channel)
DDR5-4800 4800 x 8 = 38.4 GB/s
DDR5-5600 5600 x 8 = 44.8 GB/s
DDR5-6400 6400 x 8 = 51.2 GB/s
Per socket:
desktop, 2 channels of DDR5-5600 2 x 44.8 = 89.6 GB/s
Same money, dual-channel board:
one DIMM of DDR5-6400 1 x 51.2 = 51.2 GB/s
two DIMMs of DDR5-4800 2 x 38.4 = 76.8 GB/s (+50%)
Treat such numbers as ceilings, never as throughput: NVIDIA’s benchmarking guide expects a well-tuned STREAM Triad run to reach 80 to 95 percent of theoretical peak. Channel population matters more than rated speed. A half-populated board throws away 50 percent of its ceiling, while the step from DDR5-4800 to DDR5-6400 recovers 33 percent. On an 8- or 12-channel server socket with four modules fitted, you are running at a half or a third of what you paid for. Populate every channel first, then argue about speed, and when you do, remember that MHz is not MT/s, which also has the server sums.
Windows: the standby list, SysMain and PrimoCache
Windows has been caching your storage in RAM since boot, the cache has no size setting, and there is no Windows equivalent of a Linux vm.* setting to tune it. The thing that goes wrong on Windows is usually the reading: someone concludes from Task Manager that Windows is wasting memory or has run out of it, and goes looking for something to switch off.
Cached, Available, Free: three numbers that overlap
Microsoft’s own definitions, from its walkthrough of the Task Manager memory view (May 3, 2013, on Windows Server 2008 R2): Cached is the system working set plus the standby list and the modified page list; Available is the standby, free and zero page lists; Free is the free and zero lists alone. Task Manager on Windows 10 and 11 prints Cached and Available; Free is now in Resource Monitor. Standby pages count in both Cached and Available, on purpose: they hold cached file data, and they are the first memory handed to a new allocation. The pages that genuinely cost something to reclaim are the dirty ones, counted by \Memory\Modified Page List Bytes, the nearest counterpart to Linux’s Dirty.
The only supported way to bound the cache is the API pair GetSystemFileCacheSize and SetSystemFileCacheSize, which need the SE_INCREASE_QUOTA_NAME privilege; no registry value does it. Windows also fails differently under pressure: past its commit limit of roughly RAM plus the page file, allocations fail and applications report out of memory. Linux kills a process; Windows refuses an allocation.
SysMain: leave it on
SysMain, formerly SuperFetch, profiles page use over time and asks the memory manager to preload file pages into the standby list. It reserves nothing: everything it loads can be reclaimed at once, which is why “SysMain is eating my RAM” is a misreading of the Cached figure. Microsoft publishes no general recommendation to disable SysMain. The common advice to disable it on an SSD has no Microsoft document behind it; the one Microsoft support article on SysMain CPU use concerns Windows 7 SP1 and a particular kind of 64-bit build, and its fix is to rebuild the application. Disable it only as a diagnostic, when the svchost that hosts it is plainly and persistently burning CPU or disk, and expect slower cold application launches in exchange. The documented controls are in the MMAgent PowerShell module, not the registry:
Get-MMAgent
Disable-MMAgent -ApplicationLaunchPrefetching # alias -alp
Enable-MMAgent -MemoryCompression # alias -mc
Memory compression has been on by default since Windows 10 version 1511. RAMMap, from Sysinternals, is the tool Microsoft’s cache troubleshooting points to for what is actually in the cache: its File Summary tab lists the files resident in RAM, which no counter will tell you, and its Empty menu is a diagnostic gesture, not a tuning step.
An external drive caches no writes by default
Since Windows 10 version 1809 an external drive defaults to Quick removal, under which, says Microsoft’s page on the policy (August 18, 2025), “Windows can’t cache disk write operations”. Better performance lets it, and then you must use Safely Remove Hardware or “risk losing data”. The setting is in Disk Management: right-click the drive’s label, then Properties, then Policies (on some versions, Hardware first).
RAM disks are third-party, and hold the only copy
Windows ships no supported general-purpose RAM disk. The inbox ramdisk.sys driver exists to boot Windows PE from an image, and the RAMDisk driver in the WDK is sample code, so every RAM disk on Windows is somebody else’s kernel driver. ImDisk is the usual free choice, and its own upstream now describes the design as legacy and not recommended for recent versions of Windows. SoftPerfect RAM Disk is commercial and can save its contents to an image file at shutdown, which helps only on a clean shutdown; a crash still loses everything. A RAM disk suits scratch data you can regenerate, and nothing else.
PrimoCache: what it adds, and what it risks
PrimoCache is the Windows tool with a real write cache. Its Level-1 cache is RAM, optionally including “OS Invisible Memory” that the running Windows cannot address; Level-2 is flash and persists across restarts. The cache block size runs from 4 KB to 512 KB, and the vendor advises a value at or below the filesystem’s cluster size.
On the read side, Windows already caches file data in the standby list, so the standby-lifetime counter is still the reading that says whether more read cache would help. The feature that changes behavior is Defer-Write. Defer-Write acknowledges the write to Windows before the disk has it, and starts flushing it once the Latency you type, in seconds, runs out, with 0 turning deferral off. The vendor’s own words: on “a sudden power failure, system crash or freeze, the data will have no chance to be written to the disk, resulting in loss”, the deferred data “may include file system metadata”, and in extreme cases the filesystem “may even be damaged”. The risk is identical for the RAM and SSD levels, because the cache index lives in memory either way, and an SSD tier does not make a deferred write crash-safe. A ten-second Latency is a ten-second promise you are making to yourself.
So use Defer-Write only for data you can lose or regenerate, keep the Latency short, and put the machine on a UPS that is wired to shut it down. When the working set will not fit in RAM at any price your platform supports, the Level-2 flash tier is the honest next step, and the sizing question moves to the drive, which NVMe caching covers.
Linux: the page cache and the dirty window
Almost everything Linux reports as cache is clean file data, and a clean page is dropped by unlinking it from a list, with no disk I/O at all. The number that decides whether a machine is safe is not how much is cached but how much of the cache is dirty, because dirty pages are the only ones that cost time to reclaim and the only ones whose contents exist nowhere else yet.
The dirty window
The defaults come from the initializers in mm/page-writeback.c; the kernel’s vm.rst describes these knobs without stating their values.
| sysctl | Unit | Default |
|---|---|---|
vm.dirty_background_ratio |
percent of dirtyable memory | 10 |
vm.dirty_ratio |
percent of dirtyable memory | 20 |
vm.dirty_background_bytes |
bytes | 0, disabled |
vm.dirty_bytes |
bytes | 0, disabled |
vm.dirty_expire_centisecs |
centiseconds | 3000, so 30 s |
vm.dirty_writeback_centisecs |
centiseconds | 500, so 5 s |
The percentages are not of installed RAM but of “total available memory that contains free pages and reclaimable pages”, which moves as the workload moves. The ratio and bytes forms are mutually exclusive: writing one makes the other read back as 0. Crossing the background threshold wakes the flusher threads while the writer carries on; past the midpoint of the two, about 15 percent on stock settings, the kernel starts pausing the writing process, and the pauses lengthen as dirty memory climbs toward dirty_ratio. Much published advice still quotes dirty_ratio = 40, which stopped being the default in Linux 2.6.22, in 2007.
The arithmetic on a 64 GB machine, with the dirtyable figure and the drain rate both assumed rather than read:
dirtyable memory, as a round figure ~50 GiB
dirty_background_ratio = 10 -> flushing starts at ~5 GiB dirty
dirty_ratio = 20 -> writers throttled at ~10 GiB dirty
10 GiB = 10,737,418,240 bytes
drained at an assumed 200 MB/s: 10,737,418,240 / 200,000,000 = 53.7 s
On stock settings, a 64 GB machine will happily hold several gigabytes of acknowledged writes that have never reached a disk. The time exposure is separate from the volume: a page must age 30 seconds before periodic writeback takes it, and the flusher threads look every 5 seconds, so a power cut can lose up to about 35 seconds of writes the application was told had succeeded. Setting vm.dirty_writeback_centisecs to 0 disables periodic writeback altogether and makes that window unbounded.
The standard fix is to replace the ratios with absolute limits sized to one to a few seconds of the device’s write bandwidth, then confirm the kernel agrees:
# background flush at 512 MiB, hard throttle at 2 GiB
sysctl -w vm.dirty_background_bytes=536870912
sysctl -w vm.dirty_bytes=2147483648
# read the computed thresholds back, in pages
grep -E 'nr_dirty_(background_)?threshold' /proc/vmstat
# nr_dirty_threshold 524288 -> 524288 x 4096 = 2 GiB
Persist it in a file under /etc/sysctl.d/.
The other knobs, and when to touch them
Leave them at their defaults until a reading says otherwise.
| Setting | Default | Change it only when |
|---|---|---|
vm.swappiness |
60, range 0 to 200 | vmstat 1 shows sustained si and so beside a large cache: lower it. Raise it past 100 when swap is zram or zswap, compressed in RAM |
vm.vfs_cache_pressure |
100 | A metadata-heavy job (rsync, a backup walk, a mail spool) is barely faster on its second pass: try 50. Never 0, which “can easily lead to out-of-memory conditions” |
Readahead, read_ahead_kb |
128 KiB floor, often more on hard drives | Large sequential reads run below the drive’s rating with the CPU idle: raise it. Random reads whose hit ratio will not climb: lower it |
vm.zone_reclaim_mode |
disabled | Never, for a cache: enabled, it makes the kernel throw away local page cache to avoid a cheap read from another node’s memory |
Swappiness is a price ratio between two evictions, not an eagerness dial, and the old instruction to set it to 0 was written when the range stopped at 100; 0 is not an off switch. Readahead has two traps: read_ahead_kb is in KiB while blockdev --getra counts 512-byte sectors, so 128 KiB is 256 sectors; and on an MD or device-mapper stack only the top-level device’s value counts, so tuning the member disks silently changes nothing.
On a file server over a large tree, prove the vfs_cache_pressure change with a timed walk rather than a feeling:
sysctl -w vm.vfs_cache_pressure=50
sync; echo 3 > /proc/sys/vm/drop_caches # benchmarking only
time find /srv/export -type f | wc -l # cold
time find /srv/export -type f | wc -l # warm
grep -E 'SReclaimable|^Cached' /proc/meminfo
The cold-to-warm ratio is the value of the cache, stated in seconds. The metadata lands in SReclaimable, not in Cached, which is the sign that you are measuring the dentry and inode caches rather than the page cache.
tmpfs, RAM disks and compressed swap
tmpfs keeps files in the page cache, counts them as Shmem, can write them to swap, and returns an ordinary “no space” error to the writer when it fills. With no size given it defaults to 50 percent of physical RAM. Always set size=: the kernel warns that “if you oversize your tmpfs instances the machine will deadlock since the OOM handler will not be able to free that memory.” ramfs has no size limit at all and grows until the machine runs out of memory. The brd RAM-disk driver is for the one case where you need a block device in RAM; for a fast scratch directory, tmpfs wins on every axis.
zram and zswap compress memory rather than cache storage. zram is a compressed block device, safer as swap than carrying a filesystem; zswap is a compressed cache in front of an existing swap device, so when compression stops paying it degrades to slower rather than to an out-of-memory kill. Fedora has enabled swap on zram by default since Fedora 33; Ubuntu 26.04.1 LTS ships zswap compiled in and switched off.
ZFS: the ARC in brief
On OpenZFS 2.3 and later, the ARC’s default maximum on Linux is the larger of installed memory minus 1 GiB and five-eighths of installed memory, which on any machine with more than about 2.7 GiB of RAM means memory minus 1 GiB: a 64 GiB server lets the ARC grow to 63 GiB. Before that, Linux used half of memory, which is why so much published advice disagrees. The ARC gives memory back under pressure, so the question is what it should hold, not how little. Defaults move between releases, so run man 4 zfs on the machine in front of you.
To cap it, because you decided to rather than because the default suited you:
cat /sys/module/zfs/parameters/zfs_arc_max
echo 17179869184 > /sys/module/zfs/parameters/zfs_arc_max # 16 GiB, now
printf 'options zfs zfs_arc_max=17179869184\n' > /etc/modprobe.d/zfs.conf
# root-on-ZFS: the module loads from the initrd, so rebuild it the way your
# distribution does - on Debian and Ubuntu that is update-initramfs -u
Lowering the cap below the ARC’s current size will not shrink it without memory pressure to induce shrinking. Per dataset, primarycache=metadata keeps only metadata in the ARC, which OpenZFS recommends for InnoDB data and log datasets and for a swap zvol. Advice to tune zfs_arc_meta_limit is stale: that tunable and its siblings were removed in OpenZFS 2.2.
Size it by measurement:
zarcstat -f time,read,dread,dh%,dm%,mrug,mfug,arcsz,c 1 # arcstat before 2.4
The headline hit% is polluted by prefetch, so a pool doing large sequential reads shows a superb ratio that says nothing about whether the working set is resident. Read dh% and dm%, the demand hit and miss percentages, and above all mrug and mfug, the ghost-list hits per second: requests that would have hit had the ARC been larger. Sustained ghost hits are the most direct measured argument for buying memory; a flat ghost-hit line means more RAM buys the cache nothing. Sample with an interval, because zarcsummary (arc_summary before OpenZFS 2.4.0) prints counters accumulated since boot.
The 1 GB of RAM per TB rule is in no OpenZFS document, and the NAS guide traces where it came from. An 80 TB archive read sequentially is content with 32 GB; an 8 TB pool of random 8 K database reads is not.
Deduplication is the one feature that does turn capacity into a RAM bill, because the dedup table must be resident: OpenZFS puts it at “slightly more than 320 bytes of memory” per cached entry, and entries scale with block count, not bytes.
10 TiB unique / 128 KiB recordsize = 83,886,080 blocks -> ~26.8 GB of DDT
10 TiB unique / 16 KiB recordsize = 671,088,640 blocks -> ~215 GB of DDT
Two more things belong in any ZFS memory plan. ZFS checksums each block from whatever is in RAM at the moment it is written, so a bit flipped before that produces a block with a perfectly valid checksum and the wrong contents, which every scrub will then confirm: the ECC argument at its sharpest. And when ghost hits stay high with the ARC as large as the board allows, the next tier is flash. An L2ARC fills slowly, at a default nominal 32 MiB a second since OpenZFS 2.2.7. It is a different purchase from more DIMMs, covered in NVMe caching, and the drives for the pool itself in drives for a NAS.
Power cuts: bound the window, because you cannot close it
Every cache in this guide is volatile, and no setting changes that. A safeguard answers a narrower question: at any instant, how many of your bytes exist in RAM alone, and for how many seconds?
What each stack loses
| Stack | On an unclean stop |
|---|---|
| Page cache over ext4/XFS | Journal replays; up to about 35 s of data gone (30 s to expire plus one 5 s writeback pass). On ext4, commit=5 bounds metadata loss at 5 s and the default data=ordered orders data before the metadata that names it; XFS has neither option and relies on its own log |
tmpfs, ramfs, brd |
Everything, always. tmpfs pages may sit in swap, which is not persistence |
| ZFS ARC | The ARC is a cache; durability lives in the intent log and transaction groups. OpenZFS tells PostgreSQL users to set full_page_writes = off “as ZFS will never commit a partial write” |
| Windows write caching | Memory\Modified Page List Bytes is the exposure, and PrimoCache’s Defer-Write adds the Latency you set and the flush after it, possibly including filesystem metadata |
What fsync covers, and the rest of the chain
fsync(2) flushes a file’s modified data and metadata “to the disk device”, including “writing through or flushing a disk cache if present”. Software that cares about durability calls it; the dirty window applies to everything else. What it does not cover:
- The parent directory.
fsync()“does not necessarily ensure that the entry in the directory containing the file has also reached disk”; write-then-rename needs anfsyncon the directory too. O_DIRECT. It bypasses the page cache, not the drive’s own volatile write cache, and it is not a durability primitive;O_SYNCis the flag that asks for one.- The device’s write cache.
cat /sys/block/sda/queue/write_cachereturnswrite backorwrite through. Mounting ext4 withnobarrierlets everyfsync()above it return before the data is safe; the kernel documentation calls disabling barriers safe only “if your disks are battery-backed in one way or another”. - The filesystem’s own interval. ext4 defaults to
commit=5, and the kernel documentation says plainly that “if you lose your power, you will lose as much as the latest 5 seconds of metadata changes”.
The NVMe specification defines the hardware that ends this chain: if a controller “is able to guarantee that data present in a write cache is written to non-volatile media on loss of power, then that write cache is considered non-volatile”. That is power-loss protection, and it is why a capacitor-backed data center drive is fast at fsync() while a consumer one either is slow or acknowledges writes still held in volatile cache.
What a UPS buys
Time, and an orderly shutdown during which the operating system flushes, the database checkpoints and the drive empties its cache. That is all a UPS buys, and a laptop’s charged battery does the same for a power cut. It does nothing for a kernel panic, an out-of-memory kill or a failed power supply; nothing if no software is wired to it, in which case it delays the crash by ten minutes; and nothing if its runtime is shorter than the drain time worked out above. Its sealed lead-acid (VRLA) batteries age out in a few years and fail quietly. PostgreSQL’s manual makes the general point: “High quality hardware alone is not a sufficient justification for turning off fsync.”
ECC, and why a write cache makes the case
A dirty page is the authoritative copy until it is written, so a bit flipped in it is written to storage as truth, and every checksum, replica and backup downstream records the corrupted value faithfully. In Google’s fleet study more than 8 percent of DIMMs were affected by errors in a year, and the errors were dominated by hard faults rather than cosmic rays. DDR5’s mandatory on-die ECC corrects errors inside the chip and protects nothing on the way to the CPU, so a non-ECC DDR5 module is a non-ECC module. For a NAS or server holding a large write cache or a ZFS pool, buy ECC modules on a platform that supports them; ECC vs non-ECC has the full argument, which platforms qualify, and why an everyday desktop can skip it.
And none of it is a backup. A cache is a copy of something else right up until it is the only copy, and a snapshot of a corrupted buffer is a faithful snapshot. Back up the data, test a restore, and treat the cache as what it is: speed rented from a volatile device.
Databases and application caches, briefly
Database engines keep their own caches, and disagree about their size because they disagree about who owns the copy. MySQL’s manual says “up to 80% of physical memory is often assigned to the buffer pool” on a dedicated server; PostgreSQL’s says 25 percent of RAM, and that more than 40 percent is unlikely to work better than a smaller amount. InnoDB keeps the only cached copy itself and, since MySQL 8.4, opens its data files with O_DIRECT by default where the platform supports it, so little is left in the kernel’s cache. PostgreSQL reads through the page cache on purpose, “because PostgreSQL also relies on the operating system cache”. mysqld --innodb-dedicated-server does the sizing itself: half of detected memory between 1 GB and 4 GB, three-quarters above 4 GB.
On ZFS the operating system’s cache is the ARC, so a buffer pool and the ARC can hold the same block against the same RAM. OpenZFS’s guidance for InnoDB is primarycache=metadata on the data and log datasets, with recordsize=16K for the data.
PostgreSQL’s shared_buffers and InnoDB’s buffer pool both default to 128 MB, memcached to 64 MB, and Redis to no memory limit at all with a noeviction policy, which refuses writes rather than evicting once a limit is set. A 256 GB server running any of those at its default has hundreds of gigabytes doing nothing and an application cache sized for a workstation. PostgreSQL’s effective_cache_size, default 4 GB, allocates nothing: it tells the query planner how much cache to assume, and left at 4 GB on a large machine it pushes the planner toward sequential scans on queries that should use an index. Write the unit on both settings, because PostgreSQL reads a bare number as 8 kB blocks: shared_buffers = 4096 is 32 MB, not 4 GB.
An application cache such as Redis or memcached stores the result of work rather than file data, so it saves the work, not just a read; it is also a second copy taken out of the same DIMMs, to be sized, bounded and monitored. A write-heavy Redis instance with persistence on can use up to twice its normal memory during a save.
When more RAM is the wrong purchase
A cache pays only where it changes the hit ratio, and in six common cases the next module changes little or nothing.
The machine starts from a hard drive and is not paging. Every first read after a restart still goes to the disk, so the SSD comes first.
The working set is larger than anything you can buy. A 40 TB working set of random reads with 512 GB of RAM is nowhere near the crossover in the arithmetic above, and doubling the RAM moves the hit ratio from about 1 percent to about 2.5 percent while the miss term stays exactly where it was. Putting flash under the disks lowers the miss cost by roughly a hundredfold, which raises the miss ratio you can afford by roughly the same factor.
The workload reads each block once. A backup, a media transcode, a nightly extract. The tell is in the counters: a large Inactive(file) against a small Active(file), nr_recently_evicted near zero, and a hit ratio that never improves however much of the file is resident. The knobs that move it are readahead, posix_fadvise with POSIX_FADV_SEQUENTIAL (which doubles the readahead window for that file), and the sequential bandwidth of the device itself.
The platform has run out of slots, channels and electrical budget. On a laptop with soldered memory that wall arrives before the first upgrade. Past the ceiling the economics invert. The last supported module for an old generation frequently costs more than a whole newer machine, and the older board often has 2, 4 or 6 memory channels where a current one has 8 or 12, so its bandwidth ceiling was already the lower one before capacity ran out. If the old socket’s price per gigabyte is the higher one, the honest purchase is a different platform or a second machine.
The bottleneck was never storage. Memory bought for a CPU-bound or network-bound workload sits idle. If full avg60 is flat, major faults are near zero and the Windows standby cache lives for hours, the storage path is not what limits the machine, and more RAM will change a number nobody is waiting on.
The application’s own cache was never configured. The defaults in the databases section are sized for a workstation. Raising them is free, and needs no purchase order.
What the cache was all along
The cache is not something to install. It has been running since the machine booted, in the standby list on Windows, the page cache on Linux and the ARC on ZFS. Capacity decides how large it can be, and configuration decides what it may hold. When the measurement says capacity is the limit, the modules are a desktop kit, a laptop SODIMM or, on a server, second-hand registered parts, and buying used RAM on eBay has the checks for all of them. And when the working set will never fit, the next question is what sits between the cache and the platters: on one machine usually an SSD, and on a server or NAS a cache in front of the drives.