Skip to content

Virtual memory

The information refer to the swap statistics and virtual memory estimates of the system

Original source

The macOS virtual memory information are provided by MacOsVirtualMemory, which inherits VirtualMemory

KInfo's source

val globalMemory = hardware.globalMemory
val virtualMemory: VirtualMemory = globalMemory.virtualMemory

See global memory for the containing API

Properties

swapTotal

The total swap space in bytes

val swapTotal: Long = virtualMemory.swapTotal

println(swapTotal) // e.g. 2147483648

swapUsed

The swap space currently in use in bytes

val swapUsed: Long = virtualMemory.swapUsed

println(swapUsed) // e.g. 536870912

virtualMax

The estimated virtual memory capacity in bytes, calculated as total physical memory plus total swap space

val virtualMax: Long = virtualMemory.virtualMax

println(virtualMax) // e.g. 19327352832

virtualInUse

The estimated virtual memory in use in bytes, calculated as total physical memory minus available memory plus used swap space

val virtualInUse: Long = virtualMemory.virtualInUse

println(virtualInUse) // e.g. 13421772800

swapPagesIn

The cumulative number of pages swapped in from disk

val swapPagesIn: Long = virtualMemory.swapPagesIn

println(swapPagesIn) // e.g. 65536

swapPagesOut

The cumulative number of pages swapped out to disk

val swapPagesOut: Long = virtualMemory.swapPagesOut

println(swapPagesOut) // e.g. 98304