Skip to content

Instantly share code, notes, and snippets.

@jazlopez
Last active June 28, 2021 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jazlopez/be4878e38b6bfafa71f8f4798885fbd3 to your computer and use it in GitHub Desktop.
Save jazlopez/be4878e38b6bfafa71f8f4798885fbd3 to your computer and use it in GitHub Desktop.
OSX | Example of different commands displaying memory usage
# Jaziel Lopez <juan.jaziel at gmail.com>
# Background:
# `free`is an utility command to display available memory in linux installation
#
# OSX does not ship `free` by default though alternatives exits.
# ==================================================================================
# Example of different commands displaying memory usage
#
> $ sysctl -a | grep hw\.mem | awk '{print "System Total Memory: " $2/1024/1024/1024 " Gb."}'
# System Total Memory: 16 Gb.
> $ memory_pressure
# The system has 2147483648 (524288 pages with a page size of 4096).
# Stats:
# Pages free: 93757
# Pages purgeable: 426583
# Pages purged: 100284
# Swap I/O:
# Swapins: 4394518
# Swapouts: 4562893
# Page Q counts:
# Pages active: 1962092
# Pages inactive: 1160853
# Pages speculative: 8825
# Pages throttled: 0
# Pages wired down: 671009
# Compressor Stats:
# Pages used by compressor: 295263
# Pages decompressed: 5027905
# Pages compressed: 6429165
# File I/O:
# Pageins: 3126315
# Pageouts: 7784
# System-wide memory free percentage: 76%
> $ vm_stat
# Mach Virtual Memory Statistics: (page size of 4096 bytes)
# Pages free: 54315.
# Pages active: 2061840.
# Pages inactive: 1090096.
# Pages speculative: 14180.
# Pages throttled: 0.
# Pages wired down: 677793.
# Pages purgeable: 425760.
# "Translation faults": 85656803.
# Pages copy-on-write: 2792515.
# Pages zero filled: 35527504.
# Pages reactivated: 492638.
# Pages purged: 100284.
# File-backed pages: 446195.
# Anonymous pages: 2719921.
# Pages stored in compressor: 930489.
# Pages occupied by compressor: 293880.
# Decompressions: 5032910.
# Compressions: 6429165.
# Pageins: 3129691.
# Pageouts: 7784.
# Swapins: 4394518.
# Swapouts: 4562893.
> $ sysctl vm.swapusage
# vm.swapusage: total = 2048.00M used = 542.25M free = 1505.75M (encrypted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment