[Linux] Linux smaps接口文件结构
生活随笔
收集整理的這篇文章主要介紹了
[Linux] Linux smaps接口文件结构
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在Linux內(nèi)核 2.6.16中引入了一個系統(tǒng)內(nèi)存接口特性,這個接口位于/proc/$pid/目錄下的smaps文件中?,一看內(nèi)容發(fā)現(xiàn)是進程內(nèi)存映像信息,比同一目錄下的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以上述輸出結(jié)果為例:400df000-4048c000 r--s 00000000 1f:05 286 /data/dalvik-cache/system@framework@core.jar@classes.dex
- 400df000-4048c000 是該虛擬內(nèi)存段的開始和結(jié)束位置
- r--s內(nèi)存段的權(quán)限,最后一位p代表私有,s代表共享
- 00000000 該虛擬內(nèi)存段在對應(yīng)的映射文件中的偏移量
- 1f:05 文件的主設(shè)備和次設(shè)備號
- 286 被映射到虛擬內(nèi)存的文件的索引節(jié)點號
- /data/dalvik-cache/system@framework@core.jar@classes.dex 被映射到虛擬內(nèi)存的文件名稱。后面帶(deleted)的是內(nèi)存數(shù)據(jù),可以被銷毀。
- size 是進程使用內(nèi)存空間,并不一定實際分配了內(nèi)存(VSS)
- Rss是實際分配的內(nèi)存(不需要缺頁中斷就可以使用的)
- Pss是平攤計算后的使用內(nèi)存(有些內(nèi)存會和其他進程共享,例如mmap進來的)
- Shared_Clean 和其他進程共享的未改寫頁面
- Shared_Dirty 和其他進程共享的已改寫頁面
- Private_Clean 未改寫的私有頁面頁面
- Private_Dirty 已改寫的私有頁面頁面
- Referenced 標記為訪問和使用的內(nèi)存大小
- Anonymous 不來自于文件的內(nèi)存大小
- Swap 存在于交換分區(qū)的數(shù)據(jù)大小(如果物理內(nèi)存有限,可能存在一部分在主存一部分在交換分區(qū))
- KernelPageSize 內(nèi)核頁大小?
- MMUPageSize??? MMU頁大小,基本和Kernel頁大小相同
其中Dirty頁面如果沒有交換機制的情況下,應(yīng)該是不能回收的。
精確分析內(nèi)存占用可以用Private內(nèi)存信息來衡量。?
?
詳細解釋見 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. 《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的[Linux] Linux smaps接口文件结构的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成分分析
- 下一篇: windows下tomcat自动定时重启