liveBook · Manning

Major page fault

As explained in JavaScript in Depth

A page-fault event requiring the kernel to fetch a memory page from disk.

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

How JavaScript in Depth covers it

How deep it goes
Defines the kernel-level event and interpretation conditions, but does not explain page replacement internals.
Examples
Shows a resourceUsage() snapshot with majorPageFault set to zero and recommends interval deltas from repeated samples.
What you can do after
Operate process.resourceUsage() to inspect the counter and diagnose paging trends from sampled deltas.
How it connects
Connects major page faults with swap, memory pressure, Out Of Memory failures, memory-mapped files, shared libraries, and getrusage.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of JavaScript in Depth. The section links point to the parts of the book it draws on.