zoukankan      html  css  js  c++  java
  • linux-命令-pmap相关

    概述

    用于查看某个进程的 mmap 内存。

    实例场景

    例如我想知道某一个 进程(pid)分配的内存的情况,分配了那些内存地址,总的大小又有多大,就可以使用 pmap ,根绝具体的例子可以查看 Spring Boot “内存泄漏”?看看美团大牛是如何排查的

    使用

    使用我们直接

    man pmap 
    
    NAME
           pmap - report memory map of a process
    
    SYNOPSIS
           pmap [ -x | -d ] [ -q ] pids...
           pmap -V
    
    DESCRIPTION
           The pmap command reports the memory map of a process or processes.
    
    GENERAL OPTIONS
           -x   extended       Show the extended format.
           -d   device         Show the device format.
           -q   quiet          Do not display some header/footer lines.
           -V   show version   Displays version of program.
    
    EXTENDED AND DEVICE FORMAT FIELDS
           Address:   start address of map
           Kbytes:    size of map in kilobytes
           RSS:       resident set size in kilobytes
           Dirty:     dirty pages (both shared and private) in kilobytes
           Mode:      permissions on map: read, write, execute, shared, private (copy on write)
           Mapping:   file backing the map, or ’[ anon ]’ for allocated memory, or  ’[ stack ]’ for the program stack
           Offset:    offset into the file
    
    

    例如我输入

    pmap -x  22243 
    
    00002ba744000000    1920    1844    1844 rw---    [ anon ]
    00002ba7441e0000   63616       0       0 -----    [ anon ]
    00002ba748000000    1800    1800    1800 rw---    [ anon ]
    00002ba7481c2000   63736       0       0 -----    [ anon ]
    00007ffdc7eee000      84      36      36 rw---    [ stack ]
    00007ffdc7f06000       4       4       0 r-x--    [ anon ]
    ffffffffff600000       4       0       0 r-x--    [ anon ]
    ----------------  ------  ------  ------
    total kB         7981256 1246612 1232744
    
    

    其中第二项就是实际占用内存大小,该例子中是占用了1.2G 的内存。

    参考

    • https://mp.weixin.qq.com/s/K-6CPo1haIe65KZPdTHSrA
  • 相关阅读:
    MyBatis(六)、事务控制
    MyBatis(五)、CRUD操作与重要参数及标签
    Java学习笔记-2020学习目录
    Java学习笔记(十四) 字符串
    Java学习笔记(十三) 面向对象基础
    Java学习笔记(十二) 基础知识练习
    Java学习笔记(十一) Debug
    Java学习笔记(十) 方法
    Java学习笔记(九) 数组
    Java学习笔记(八) IDEA
  • 原文地址:https://www.cnblogs.com/Benjious/p/13265981.html
Copyright © 2011-2022 走看看