[Linux] Linux smaps介面檔案結構

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   使用   ar   for   檔案   

在Linux核心 2.6.16中引入了一個系統記憶體介面特性,這個介面位於/proc/$pid/目錄下的smaps檔案中 ,一看內容發現是進程記憶體映像資訊,比同一目錄下的maps檔案更詳細些。

400df000-4048c000 r--s 00000000 1f:05 286        /data/dalvik-cache/[email protected]@[email protected]Size:               3764 kBRss:                1804 kBPss:                1804 kBShared_Clean:          0 kBShared_Dirty:          0 kBPrivate_Clean:      1804 kBPrivate_Dirty:         0 kBReferenced:         1804 kBAnonymous:             0 kBSwap:                  0 kBKernelPageSize:        4 kBMMUPageSize:           4 kB

以上述輸出結果為例:400df000-4048c000 r--s 00000000 1f:05 286 /data/dalvik-cache/[email protected]@[email protected]

  • 400df000-4048c000 是該虛擬記憶體段的開始和結束位置
  • r--s記憶體段的許可權,最後一位p代表私人,s代表共用
  • 00000000 該虛擬記憶體段在對應的對應檔中的位移量
  • 1f:05 檔案的主裝置和次裝置號
  • 286 被映射到虛擬記憶體的檔案的索引節點號
  • /data/dalvik-cache/[email protected]@[email protected] 被映射到虛擬記憶體的檔案名稱。後面帶(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 themapping 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), theprocess‘ proportional share of this mapping (PSS), the number of clean anddirty private pages in the mapping.  Note that even a page which is part of aMAP_SHARED mapping, but has only a single pte mapped, i.e.  is currently usedby 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.  Evena mapping associated with a file may contain anonymous pages: when MAP_PRIVATEand 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 onswap.

[Linux] Linux smaps介面檔案結構

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.