Intro

  • 常用命令

free
free -h 以更易读(human-readable)的格式输出
free -s 3 每3秒输出一次

  • 示例
wuyujin1997@budy:~$ free -htotal        used        free      shared  buff/cache   available
Mem:           985M        253M        124M        2.7M        607M        566M
Swap:            0B          0B          0B
wuyujin1997@budy:~$
  • 行列意义

先区分行:

  • Mem 真正的物理内存
  • Swap 交换空间(物理量内存过小时利用了硬盘空间进行“中转”的空间)

再区分列:

  • total 机器的整体内存大小(物理内存 + 处于硬盘区的交换空间)

  • used 已使用的内存大小,计算方式: total - free - buffers - cache

  • free 未使用/空闲的内存

  • shared 共享内存(tmpfs使用的内存)

  • buff/cache 内核使用的缓冲块buffer、页面缓存cache。

  • available 估算在不使用交换空间的前提下,有多少内存可用于新启动的程序运行。

  • 表格分析

              total        used        free      shared  buff/cache   available
Mem:           985M        253M        124M        2.7M        607M        566M
Swap:            0B          0B          0B

由表格可见,我的机器:
内存大小total为:985M
已使用内存used为: 253M
空闲内存free为:124M
buff/cache之和为607M
而:已使用内存 + 空闲内存 + buff/cache = 253 + 124 + 607 = 984M 约等于整体内存985M

两个核心指标:
total 机器整体内存有985M
available 新运行程序的可用内存大小为566M(而非free的124M)

available是大于free值的,因为如果新启动的程序内存不够用,可以去回收buff/cache的大小来运行新的程序。
可得available的值上限:free+buff/cache
即:0 < available < (free + buff/cache) 毕竟buff/cache使用的内存是不能被全部回收的。

程序文档

  • 查看free命令的使用手册

man free

NAMEfree - Display amount of free and used memory in the systemSYNOPSISfree [options]DESCRIPTIONfree  displays  the total amount of free and used physical and swap memory in the system, as well as the buffersand caches used by the kernel. The information is gathered by parsing /proc/meminfo. The displayed columns are:total  Total installed memory (MemTotal and SwapTotal in /proc/meminfo)used   Used memory (calculated as total - free - buffers - cache)free   Unused memory (MemFree and SwapFree in /proc/meminfo)shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)buffersMemory used by kernel buffers (Buffers in /proc/meminfo)cache  Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo)buff/cacheSum of buffers and cacheavailableEstimation of how much memory is available for starting new applications, without  swapping.  Unlike  thedata provided by the cache or free fields, this field takes into account page cache and also that not allreclaimable memory slabs will be reclaimed due to items being  in  use  (MemAvailable  in  /proc/meminfo,available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free)
...

可见:free命令的输出信息是基于/proc/meminfo文件的

  • 查看系统文件

more /proc/meminfo

wuyujin1997@budy:~$ more /proc/meminfo
MemTotal:        1008720 kB
MemFree:          123096 kB
MemAvailable:     575792 kB
Buffers:          145400 kB
Cached:           398732 kB
SwapCached:            0 kB
Active:           622084 kB
Inactive:         141012 kB
Active(anon):     219436 kB
Inactive(anon):     2348 kB
Active(file):     402648 kB
Inactive(file):   138664 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               372 kB
Writeback:             0 kB
AnonPages:        219020 kB
Mapped:            92012 kB
Shmem:              2820 kB
Slab:              93564 kB
SReclaimable:      77848 kB
SUnreclaim:        15716 kB
KernelStack:        2988 kB
PageTables:         7156 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      504360 kB
Committed_AS:     906428 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       85888 kB
DirectMap2M:      962560 kB
DirectMap1G:           0 kB
wuyujin1997@budy:~$

Linux free 查看内存使用情况 常用命令相关推荐

  1. linux系统命令-查看内存使用情况

    1.查看系统内存占用 free -m [root@localhost ~]# free -mtotal used free shared buffers cached Mem: 2004 573 14 ...

  2. linux脚本查看系统内存,二个linux下查看内存使用情况的shell脚本()

    摘要 腾兴网为您分享:二个linux下查看内存使用情况的shell脚本(),政务易,悦作业,优化大师,王者荣耀等软件知识,以及单向历app,优路教育app,kimoji,开关电源设计软件,皮皮高清影视 ...

  3. Linux网络——查看网络连接情况的命令

    Linux网络--查看网络连接情况的命令 摘要:本文主要学习了Linux中用来查看网络连接情况的命令. hostname命令 hostname命令用于显示和设置系统的主机名称,设置只是临时生效,永久生 ...

  4. Linux服务器查看内存使用情况

    前言 在日常开发或者生产环境,我们经常需要查看linux服务的内存使用情况,所以熟练敲出命令能便于我们快速定位问题,这里来和大家一起学习linux的常用查看内存命令. free命令 free 命令显示 ...

  5. 【linux】查看内存使用情况

    内存使用量排序显示 top命令查看 top命令能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器.使用top命令可以轻松查看各个应用的内存使用情况. # top -d 1 在t ...

  6. Linux下查看内存使用情况方法总结

    关注.星标公众号,直达精彩内容 来自:Specs'Blog 链接:http://9iphp.com/linux/1247.html 原文:http://ask.xmodulo.com/check-me ...

  7. linux下查看内存使用情况

    在Linux下查看内存我们一般用free命令: [root@scs-2 tmp]# free              total       used       free     shared   ...

  8. linux内存平均值,linux下查看内存使用情况[转载]

    在Linux下查看内存我们一般用free命令: [root@scs-2 tmp]# free total used free shared buffers cached Mem: 3266180 32 ...

  9. linux centos 查看内存使用情况

    1.ps -ef|grep java (查看所有java运行的进程) 2.df -h (查看磁盘使用情况) 3.free -m|g (m和g表示单位,二选一)查看内存使用情况 4.top (实时显示系 ...

最新文章

  1. 同事问我MySQL怎么递归查询,我懵逼了...
  2. [概统]本科二年级 概率论与数理统计 第一讲 古典概型
  3. 行走在成为程序猿的道路上
  4. Python ——告白小程序,添加微信号(快来设置你的freestyle吧)
  5. 贪心算法+回溯算法+动态规划
  6. 20万+奖金池,“智在飞翔”2021 • 无人飞行器智能感知大赛,战火重燃 • 等你来战!!...
  7. 和当前时间比较_货币的时间价值
  8. 光源时间_【精品透视】UVLED紫外固化光源崭露头角!
  9. jira怎么提交bug_请停止编写糟糕的提交消息!
  10. Mysql 查询某个字段最长的记录
  11. python中元组的赋值_在Python中,元组可以被赋值修改。( ) (2.0分)_学小易找答案...
  12. mysql 快日志_Mysql慢查询日志记录更快的查询
  13. ubuntu12.04安装出现系统内部错误
  14. win7怎么看计算机Mac地址,win7如何查看mac地址?win7系统查看mac地址两种方法
  15. lol更新显示正在连接服务器,正在连接服务器-lol一直显示“正在连接服务器”...
  16. STM32CubeMX | 41 - 使用LTDC驱动TFT-LCD屏幕(RGB屏)
  17. python基础入门1
  18. 微信锁屏密码怎么设置
  19. TLS 地面三维激光扫描仪
  20. ARM最强CPU/GPU来了!A75、G72首发:性能爆炸

热门文章

  1. PyOpenPose编译与使用
  2. (21) 出行需求预测新视角---基于图卷积神经网络GCN的出租车OD需求预测
  3. 敏捷框架SAFe(Scaled Agile Framework)实践
  4. 机器学习算法实践——K-Means算法与图像分割
  5. 使用 SAP UI5 绘制 Business Rule Control
  6. Linux中关于一个文件的详细信息
  7. 坚守初心,让数据成为生产力!
  8. 一次服务端大面积接口响应时间骤增问题排查
  9. 高端风再起,小爱、小度、天猫精灵发新芽?
  10. Buffon's Needle An Analysis and Simulation------蒙特卡洛法模拟蒲丰(Buffon)投针实验-使用Matlab