linux 内存利用率
系统 Centos 7.6
[root@webserver ~]# free
total used free shared buff/cache available
Mem: 32779456 20957044 2973600 426980 8848812 10945512
Swap: 4194300 0 4194300
有种说法:
可用内存 = free + buffer/cache
已用内存 = used - buffer/cache
buffer : 已分配,未释放
cache:已分配,未使用
free:未分配
但是 检查 /proc/meminfo
[root@webserver ~]# grep -E --color 'Mem|Cache|Swap' /proc/meminfo
MemTotal: 32779456 kB
MemFree: 2972992 kB
MemAvailable: 10944904 kB
Cached: 8268656 kB
SwapCached: 0 kB
SwapTotal: 4194300 kB
SwapFree: 4194300 kB
used = total - free - buffer - cache
莫非 Centos 这里used 已经减去了 buffer、cache ?
查看占多内存的单个进程:
[root@webserver ~]# ps -o pid,user,%mem,command ax|sort -b -k3 -r
PID USER %MEM COMMAND
12818 root 9.0 java -jar ruoyi-gateway.jar
1731 root 6.5 java -Dfile.encoding=utf-8 -jar yachtar-modules-alllinone-3.0.0.jar
13111 root 4.9 java -jar ruoyi-auth.jar
552 root 4.7 java -jar yachtar-modules-wechat-3.0.0.jar
14288 root 4.2 java -jar yachtar-modules-file.jar
30509 root 4.0 java -Dfile.encoding=utf-8 -jar yachtar-modules-base.jar
13271 root 3.9 java -jar ruoyi-modules-system.jar
3612 root 3.4 java -jar yachtar-modules-sms.jar
9544 root 2.8 /home/java/jdk1.8.0_181/bin/java -Djava.ext.dirs=/home/java/jdk1.8.0_181/jre/lib/ext:/home/java/jdk1. 8.0_181/lib/ext -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Dnacos.member.list= -Xloggc:/home/java/nacos/logs/nac os_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:Num berOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/java/nacos/plugins/health,/home/java/nacos/plugins/cmdb -Dn acos.home=/home/java/nacos -jar /home/java/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/j ava/nacos/conf/ --logging.config=/home/java/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288 nacos.nacos
1021 root 2.7 java -jar yachtar-modules-job.jar
18965 root 15.1 /home/java/jdk1.8.0_181/jre/bin/java -Djava.util.logging.config.file=/home/apache-tomcat-9.0.37/conf/ logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms2048m -Xmx4096m -XX:Meta spaceSize=512m -XX:MaxMetaspaceSize=768m -Xss2m -XX:-UseGCOverheadLimit -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol .handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Djava.awt.head less=true -Dignore.endorsed.dirs= -classpath /home/apache-tomcat-9.0.37/bin/bootstrap.jar:/home/apache-tomcat-9.0.37/bin/ tomcat-juli.jar -Dcatalina.base=/home/apache-tomcat-9.0.37 -Dcatalina.home=/home/apache-tomcat-9.0.37 -Djava.io.tmpdir=/h ome/apache-tomcat-9.0.37/temp org.apache.catalina.startup.Bootstrap start
6519 mysql 0.8 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/ usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mysqld.log --pid-file=/usr/local/mysql/data/mys qld.pid --port=3306
5461 root 0.5 /CloudResetPwdUpdateAgent/depend/jre/bin/java -Dorg.tanukisoftware.wrapper.WrapperSimpleApp.maxStartM ainWait=40 -Djava.library.path=../lib -classpath ../lib/resetpwdupdateagent.jar:../lib/wrapper.jar:../lib/json-20160810.j ar:../lib/log4j-api-2.8.2.jar:../lib/log4j-core-2.8.2.jar -Dwrapper.key=G1wz_sjwTSFd3zsi -Dwrapper.backend=pipe -Dwrapper .disable_console_input=TRUE -Dwrapper.pid=5388 -Dwrapper.version=3.5.26 -Dwrapper.native_library=wrapper -Dwrapper.arch=x 86 -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=180 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp CloudRe setPwdUpdateAgent
2705 root 0.3 /usr/lib/systemd/systemd-journald