• 性能监控命令 | MEMORY


    原文转自:https://www.jianshu.com/p/b54d0e424fd1

    • CPU
    • MEMORY
    • IO
    • NETWORK
    • LINUX进程内存占用查看方法

    MEMORY


    首先说说虚拟内存和物理内存:

    虚拟内存就是采用硬盘来对物理内存进行扩展,将暂时不用的内存页写到硬盘上而腾出更多的物理内存让有需要的进程来用。当这些内存页需要用的时候在从硬盘读回内存。这一切对于用户来说是透明的。通常在Linux系统说,虚拟内存就是swap分区。在X86系统上虚拟内存被分为大小为4K的页。

    每一个进程启动时都会向系统申请虚拟内存(VSZ),内核同意或者拒就请求。当程序真正用到内存时,系统就它映射到物理内存。RSS表示程序所占的物理内存的大小。用ps命令我们可以看到进程占用的VSZ和RSS。

    | [work@jx-testing-ps1933.jx.baidu.com ~]$ ps -aux
    USER PID %CPU %MEM VSZ [RSS](http://wiki.babel.baidu.com/twiki/bin/view/Com/Main/RSS) TTY STAT START TIME COMMAND
    root 1 0.0 0.0 4752 544 ? S 2007 0:01 init [3] 
    root 2 0.0 0.0 0 0 ? S 2007 0:22 [migration/0]
    root 3 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/0]
    root 4 0.0 0.0 0 0 ? S 2007 0:20 [migration/1]
    root 5 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/1]
    root 6 0.0 0.0 0 0 ? S 2007 0:18 [migration/2]
    root 7 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/2]
    root 8 0.0 0.0 0 0 ? S 2007 0:12 [migration/3]
    root 9 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/3] |
    

    在命令行使用“Free”命令可以监控内存使用情况

    | [work@tc-testing-ps5006.tc.baidu.com ~]$ free
    total used free shared buffers cached
    Mem: 8165816 8145048 20768 0 22920 5840236
    -/+ buffers/cache: 2281892 5883924
    Swap: 1024056 2316 1021740 |
    

    输出的含义

    在缺省的状态下,free命令以千字节(也就是1024字节为单位)来显示内存使用情况。可以使用—h参数以字节为单位显示内存使用情况,或者可以使用—m参数以兆字节为单位显示内存使用情况。还可以通过—s参数使用命令来不间断地监视内存使用情况。

    <p><strong>使甩vmstat命令监视虚拟内存使用情况</strong></p>
    <div class="_2Uzcx_"><button class="VJbwyy" type="button" aria-label="复制代码"><i aria-label="icon: copy" class="anticon anticon-copy"><svg
    			 viewBox="64 64 896 896" focusable="false" class="" data-icon="copy" width="1em" height="1em" fill="currentColor"
    			 aria-hidden="true">
    				<path d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"></path>
    			</svg></i></button>
    	<pre class="line-numbers  language-kotlin"><code class="  language-kotlin">| <span class="token punctuation">[</span><span class="token label symbol">work@</span>jx<span class="token operator">-</span>testing<span class="token operator">-</span>ps1933<span class="token punctuation">.</span>jx<span class="token punctuation">.</span>baidu<span class="token punctuation">.</span>com ~<span class="token punctuation">]</span>$ ps <span class="token operator">-</span>aux
    

    USER PID %CPU %MEM VSZ [RSS](http://wiki.babel.baidu.com/twiki/bin/view/Com/Main/RSS) TTY STAT START TIME COMMAND
    root 1 0.0 0.0 4752 544 ? S 2007 0:01 init [3]
    root 2 0.0 0.0 0 0 ? S 2007 0:22 [migration/0]
    root 3 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/0]
    root 4 0.0 0.0 0 0 ? S 2007 0:20 [migration/1]
    root 5 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/1]
    root 6 0.0 0.0 0 0 ? S 2007 0:18 [migration/2]
    root 7 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/2]
    root 8 0.0 0.0 0 0 ? S 2007 0:12 [migration/3]
    root 9 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/3] |


    与内存和IO相关的参数含义


  • 相关阅读:
    Linux内核使用的GNUC扩展
    linux常用命令--开发调试篇
    代码示例_poll的多路复用
    硬件_红外传感器
    硬件_霍尔感应器
    全志_功能引脚配置_sys_config.fex
    知识_嵌入式常用词汇
    代码示例_Input 按键驱动
    Vmware_安装_tools
    Ubunt_配置_start
  • 原文地址:https://www.cnblogs.com/wyf0518/p/12104838.html
Copyright © 2020-2023  润新知