githubEdit

Memory Tools

Memory inspection, monitoring, and cache management tools

free

# display memory usage in human-readable format
free -h
free -h -s 3        # refresh every 3 seconds
free -h -c 5         # refresh 5 times then exit

# output example
#               total        used        free      shared  buff/cache   available
# Mem:           15Gi       5.2Gi       2.1Gi       312Mi       8.1Gi       9.6Gi
# Swap:         2.0Gi          0B       2.0Gi

top / htop

# top - sort by memory usage
top -o %MEM

# inside top keyboard shortcuts
# M    sort by memory usage
# P    sort by CPU usage
# e    toggle memory unit (KB/MB/GB)
# 1    show per-CPU stats
# c    show full command line
# k    kill a process
# q    quit

# htop
htop
htop -u username      # filter by user
htop -p 1234,5678     # monitor specific PIDs
htop -t               # tree view

pmap

vmstat (memory columns)

drop_caches

smem

Reference:

Last updated