A major page fault occurs when the kernel must fetch a memory page from disk. A rising count can indicate swapping under memory pressure, but a near-zero count does not prove memory is healthy: systems with swap disabled may fail with an Out Of Memory error before paging occurs. section 11.1.2
Use the metric carefully:
- Read majorPageFault through process.resourceUsage(); it is a cumulative counter, so compare two samples to measure an interval. section 11.1.2
- Include paging of memory-mapped files and shared libraries, not only swap activity. section 11.1.2
- Interpret the value alongside host configuration: swap-enabled systems may page under pressure, while swap-disabled systems may terminate the process instead. section 11.1.2
console.log(process.resourceUsage());
// Prints:
{
userCPUTime: 56155,
systemCPUTime: 22434,
maxRSS: 43684,
sharedMemorySize: 0,
unsharedDataSize: 0,
unsharedStackSize: 0,
minorPageFault: 2310,
majorPageFault: 0,
swappedOut: 0,
fsRead: 0,
fsWrite: 0,
ipcSent: 0,
ipcReceived: 0,
signalsCount: 0,
voluntaryContextSwitches: 11,
involuntaryContextSwitches: 23
}Inspect a concrete resourceUsage() snapshot, including the majorPageFault field and its current value. section 11.1.2
