👌Linux内存有问题怎么查看?

👌linux 内存有问题怎么查看?

如果怀疑内存有问题,可以通过以下步骤进行检查和诊断:

1. 使用free命令查看内存使用情况

free命令可以显示系统的内存使用情况,包括总内存、已使用内存、空闲内存和缓存等信息。

1
free -h

输出示例:

1
2
3
total        used        free      shared  buff/cache   available
Mem: 7.8G 3.2G 1.5G 200M 3.1G 4.1G
Swap: 2.0G 0.0K 2.0G

2. 使用tophtop命令查看内存使用情况

tophtop命令可以实时显示系统的资源使用情况,包括内存使用情况。

  • top命令:
1
top
  • htop命令(需要安装):
1
2
sudo apt-get install htop
htop

3. 使用vmstat命令查看内存和系统性能

vmstat命令可以报告虚拟内存、进程、CPU 活动等信息。

1
vmstat 1 5

输出示例:

1
2
3
4
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 1576828 72464 2192160 0 0 8 11 64 150 1 0 99 0 0
0 0 0 1576820 72464 2192160 0 0 0 0 59 144 0 0 100 0 0

4. 检查内存使用情况的日志

查看系统日志,如/var/log/syslog/var/log/messages,看看是否有与内存相关的错误或警告。

1
2
sudo grep -i memory /var/log/syslog
sudo grep -i memory /var/log/messages
 wechat
天生我才必有用