[Linux] Linux smaps接口文件结构
生活随笔
收集整理的這篇文章主要介紹了
[Linux] Linux smaps接口文件结构
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在Linux內核 2.6.16中引入了一個系統內存接口特性,這個接口位于/proc/$pid/目錄下的smaps文件中?,一看內容發現是進程內存映像信息,比同一目錄下的maps文件更詳細些。
400df000-4048c000 r--s 00000000 1f:05 286 /data/dalvik-cache/system@framework@core.jar@classes.dex Size: 3764 kB Rss: 1804 kB Pss: 1804 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 1804 kB Private_Dirty: 0 kB Referenced: 1804 kB Anonymous: 0 kB Swap: 0 kB KernelPageSize: 4 kB MMUPageSize: 4 kB以上述輸出結果為例:400df000-4048c000 r--s 00000000 1f:05 286 /data/dalvik-cache/system@framework@core.jar@classes.dex
- 400df000-4048c000 是該虛擬內存段的開始和結束位置
- r--s內存段的權限,最后一位p代表私有,s代表共享
- 00000000 該虛擬內存段在對應的映射文件中的偏移量
- 1f:05 文件的主設備和次設備號
- 286 被映射到虛擬內存的文件的索引節點號
- /data/dalvik-cache/system@framework@core.jar@classes.dex 被映射到虛擬內存的文件名稱。后面帶(deleted)的是內存數據,可以被銷毀。
- size 是進程使用內存空間,并不一定實際分配了內存(VSS)
- Rss是實際分配的內存(不需要缺頁中斷就可以使用的)
- Pss是平攤計算后的使用內存(有些內存會和其他進程共享,例如mmap進來的)
- Shared_Clean 和其他進程共享的未改寫頁面
- Shared_Dirty 和其他進程共享的已改寫頁面
- Private_Clean 未改寫的私有頁面頁面
- Private_Dirty 已改寫的私有頁面頁面
- Referenced 標記為訪問和使用的內存大小
- Anonymous 不來自于文件的內存大小
- Swap 存在于交換分區的數據大小(如果物理內存有限,可能存在一部分在主存一部分在交換分區)
- KernelPageSize 內核頁大小?
- MMUPageSize??? MMU頁大小,基本和Kernel頁大小相同
其中Dirty頁面如果沒有交換機制的情況下,應該是不能回收的。
精確分析內存占用可以用Private內存信息來衡量。?
?
詳細解釋見 http://www.kernel.org/doc/Documentation/filesystems/proc.txt
The first of these lines shows the same information as is displayed for the mapping in /proc/PID/maps. The remaining lines show the size of the mapping (size), the amount of the mapping that is currently resident in RAM (RSS), the process' proportional share of this mapping (PSS), the number of clean and dirty private pages in the mapping. Note that even a page which is part of a MAP_SHARED mapping, but has only a single pte mapped, i.e. is currently used by only one process, is accounted as private and not as shared. "Referenced" indicates the amount of memory currently marked as referenced or accessed. "Anonymous" shows the amount of memory that does not belong to any file. Even a mapping associated with a file may contain anonymous pages: when MAP_PRIVATE and a page is modified, the file page is replaced by a private anonymous copy. "Swap" shows how much would-be-anonymous memory is also used, but out on swap. 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的[Linux] Linux smaps接口文件结构的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成分分析
- 下一篇: windows下tomcat自动定时重启