[转帖]Cheat sheet: understanding the pmap(1) output

cheat,sheet,understanding,the,pmap,output · 浏览次数 : 0

小编点评

**Pmap Cheat Sheet** | Address | Perm Offset | Device | Inode | Size | Rss | Pss | Shared_Clean | Shared_Dirty | Private_Clean | Private_Dirty | |---|---|---|---|---|---|---|---|---|---| | 00400000 | r-xp | 00000000 | 3948320 | 4 | 4 | 4 | 0 | 0 | 0 | 0 | **Key Points:** * **PSS**: Proportional Share Size, indicating the amount of private memory used by the process and shared memory used between processes. * **Private**: Memory exclusively used by this process. * **Shared**: Memory used by multiple processes, either shared directly or through libraries. * **Rss**: Resident Set Size, the amount of memory actively loaded into memory. * **Pss**: Available Share Size, the amount of shared memory available for other processes. **Observations:** * The Pss value for the first process is 2, indicating that 2 KiB of memory is shared between the two processes. * The Private values are 0 for both processes, as they are only using memory that is shared. * The new process starts with different values for Private and Shared, as it is not sharing any memory with the first process. **Conclusion:** The pmap output provides insights into the memory mapping of a running process, including the amount of private and shared memory used, as well as the available share size.

正文

https://www.labcorner.de/cheat-sheet-understanding-the-pmap1-output/

 

pmap(1) can be used to list the individual address areas which are mapped into a process. It essentially reads the /proc/$pid/smaps file and represents the data in a more readable format. On Linux, there is the command line option -XX which displays all information the kernel provides (the output might change when newer kernels provide different metrics). Lets consider the following simple C program:

#include <stdio.h>
 
int main(int argc, char *argv[]) {
getchar();
return 0;
}

We can now launch this application (called “minimal”) and call pmap with its process id:

$ ./minimal & pmap -XX $!

As a result, we get the output as shown in this cheat sheet (click on the image for a larger, readable version):

 

 

One interesting metric is the PSS value, also known as “Proportional Share Size”. This is the amount of memory which is private to the mapping, plus the partial amount of shared mappings of this process. For example, if the process has mapped 100 KiB of private memory, another 200 KiB of shared memory which is shared between two processes and another 150 KiB which is shared between three processes, the PSS is calculated like 100 KiB + 200 KiB / 2 + 150 KiB / 3 = 250 KiB. This can be directly observed when starting the “minimal” application more than once. Lets examine the first mapping which is reported my pmap when the application is started once (this is the code section of the executable) (only showing the first few columns here):

$ ./minimal & pmap -XX $!
Address Perm Offset Device Inode Size Rss Pss Shared_Clean Shared_Dirty Private_Clean Private_Dirty
00400000 r-xp 00000000 08:01 3948320 4 4 4 0 0 4 0

The application now continues to run, and we can simply start it once again and dump the mappings of this new process:

$ ./minimal & pmap -XX $!
Address Perm Offset Device Inode Size Rss Pss Shared_Clean Shared_Dirty Private_Clean Private_Dirty
00400000 r-xp 00000000 08:01 3948320 4 4 2 4 0 0 0

Here, we can observe two things:

  • The Pss value for the new process is 2, not 4 – this is because the code section is shared between two processes, the one which we started first and the one which we started second
  • The Private values are now 0, while the Shared values are now 4 – we are now sharing one page (4 KiB) between the two processes.

Furthermore, if we use pmap to examine the mapping of the first process again (assumed that its process ID was 13944), we see that also for this first process the values have changed:

$ pmap -XX 13944
13944: ./minimal
Address Perm Offset Device Inode Size Rss Pss Shared_Clean Shared_Dirty Private_Clean Private_Dirty
00400000 r-xp 00000000 08:01 3948320 4 4 2 4 0 0 0

Note that memory which can be shared (e.g. Code from a shared library) but which is mapped only into this particular process is counted as private, unless it will be mapped in at least one additional process.

与[转帖]Cheat sheet: understanding the pmap(1) output相似的内容:

[转帖]Cheat sheet: understanding the pmap(1) output

https://www.labcorner.de/cheat-sheet-understanding-the-pmap1-output/ pmap(1) can be used to list the individual address areas which are mapped into a

[转帖]聊聊Chat GPT-1到GPT-4的发展历程

http://blog.itpub.net/69925873/viewspace-2935360/ OpenAI的Generative Pre-trained Transformer(GPT)模型通过引入非常强大的语言模型,在自然语言处理(NLP)领域引起了巨大震动。这些模型可以执行各种NLP任务,

[转帖]Java Flame Graphs

https://www.brendangregg.com/blog/2014-06-12/java-flame-graphs.html Java flame graphs are a hot new way to visualize CPU usage. I'll show how to creat

[转帖]

Linux ubuntu20.04 网络配置(图文教程) 因为我是刚装好的最小系统,所以很多东西都没有,在开始配置之前需要做下准备 环境准备 系统:ubuntu20.04网卡:双网卡 网卡一:供连接互联网使用网卡二:供连接内网使用(看情况,如果一张网卡足够,没必要做第二张网卡) 工具: net-to

[转帖]

https://cloud.tencent.com/developer/article/2168105?areaSource=104001.13&traceId=zcVNsKTUApF9rNJSkcCbB 前言 Redis作为高性能的内存数据库,在大数据量的情况下也会遇到性能瓶颈,日常开发中只有时刻

[转帖]ISV 、OSV、 SIG 概念

ISV 、OSV、 SIG 概念 2022-10-14 12:29530原创大杂烩 本文链接:https://www.cndba.cn/dave/article/108699 1. ISV: Independent Software Vendors “独立软件开发商”,特指专门从事软件的开发、生产、

[转帖]Redis 7 参数 修改 说明

2022-06-16 14:491800原创Redis 本文链接:https://www.cndba.cn/dave/article/108066 在之前的博客我们介绍了Redis 7 的安装和配置,如下: Linux 7.8 平台 Redis 7 安装并配置开机自启动 操作手册https://ww

[转帖]HTTPS中间人攻击原理

https://www.zhihu.com/people/bei-ji-85/posts 背景 前一段时间,公司北京地区上线了一个HTTPS防火墙,用来监听HTTPS流量。防火墙上线之前,邮件通知给管理层,我从我老大那里听说这个事情的时候,说这个有风险,然后意外地发现,很多人原来都不知道HTTPS防

[转帖]关于字节序(大小端)的一点想法

https://www.zhihu.com/people/bei-ji-85/posts 今天在一个技术群里有人问起来了,当时有一些讨论(不完全都是我个人的观点),整理一下: 为什么网络字节序(多数情况下)是大端? 早年设备的缓存很小,先接收高字节能快速的判断报文信息:包长度(需要准备多大缓存)、地

[转帖]awk提取某一行某一列的数据

https://www.jianshu.com/p/dbcb7fe2da56 1、提取文件中第1列数据 awk '{print $1}' filename > out.txt 2、提取前2列的文件 awk `{print $1,$2}' filename > out.txt 3、打印完第一列,然后打