当前位置:首页 > 内存 > 正文

linux查看内存使用量(linux如何看内存使用量)

  • 内存
  • 2024-03-15 20:30:37
  • 8780
Linux 查看内存使用量
有多种方法可以查看 Linux 上的内存使用情况:
1. free 命令
显示系统的物理内存使用情况,包括总内存、已用内存、空闲内存和缓存。
$ free
示例输出:
total used free shared buff/cache available
Mem: 640M 256M 224M 16K 160M 368M
Swap: 128M 0B 128M
total: 系统的总物理内存大小。
used: 系统当前正在使用的物理内存数量。
free: 系统当前未使用的物理内存数量。
shared: 多个程序共享的内存数量(很少见)。
buff/cache: 用作系统缓冲区和缓存的内存数量。
available: 系统当前可用于分配给新进程的内存数量。
2. vmstat 命令
显示虚拟内存统计信息,包括处理器活动、内存使用和交换活动。
$ vmstat 1 2
示例输出:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 2336 1156 3648 0 0 0 0 519 153 5 10 85 0 0
1 0 0 2336 1156 3648 0 0 0 0 531 138 3 11 86 0 0
memory:
free: 系统当前未使用的物理内存数量。
buff: 用作系统缓冲区的内存数量。
cache: 用作系统缓存的内存数量。
3. top 命令
实时显示系统中正在运行的进程,并按内存使用量排序。
$ top
示例输出:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1080194 root 20 0 18600 2756 2668 S 0.0 4.7 14:51.31 Xorg
1141782 root 20 0 748 0 0 S 0.0 0.2 3:42.61 udisksd
1142450 root 20 0 700 24 12 S 0.0 0.0 2:39.66 upowerd
1142492 root 20 0 848 88 0 S 0.0 0.1 1:21.96 fwupd
1142473 root 20 0 716 60 4 S 0.0 0.1 0:56.89 kbd
%MEM: 进程正在使用的内存百分比。