[轉帖]Solaris記憶體管理以及判定記憶體是否夠用的方法
Solaris記憶體管理以及判定記憶體是否夠用的方法
http://blog.sina.com.cn/s/blog_592060b50100dmwa.html
Solaris記憶體管理以及判定記憶體是否夠用的方法
Solaris記憶體管理的一些基本原理
<wbr> <wbr> <wbr> 首先需要對Solairs的記憶體管理有一個基本的瞭解。Solaris記憶體管理簡單來說就是“虛擬記憶體管理”模型。(注:現代OS差不多都是虛擬記憶體管理,包括Windows,Linux)虛擬記憶體的定義是:
<wbr> <wbr> <wbr>虛擬記憶體的定義是基於對的重定義的,即把地址空間定義為連續的虛擬記憶體地址,以藉此欺騙程式,使它們以為自己正在使用一大塊的連續地址。(參見:)
<wbr> <wbr> <wbr> 虛擬記憶體也就是為了程式設計的方便,而為應用程式假象一個地址空間。就是對於64bit的Solaris來說,虛擬地址空間就是2^64Byte,基本就看成無窮大吧。;對於32位的作業系統就是4G(如果核心空間獨立的話,可能就是2G或者3G,如WindowsXP)。虛擬記憶體和實際實體記憶體的對映關係透過CPU的MMU(記憶體管理單元)來完成。
首先,透過在root許可權下執行
# echo ::memstat |mdb -k
Page Summary<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> Pages <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> MB <wbr> %Tot
------------<wbr> <wbr> <wbr> <wbr> ---------------- <wbr> ---------------- <wbr> ----
Kernel<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>49709 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 388 <wbr> <wbr> <wbr> <wbr> <wbr> 2%
Anon<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>927367 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 7245 <wbr> <wbr> <wbr> <wbr>46%
Exec and libs<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 5186 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 40 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 0%
Page cache<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 212025 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 1656 <wbr> <wbr> 11%
Free (cachelist)<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 787615 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 6153 <wbr> <wbr> 39%
Free (freelist)<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 31964 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 249 <wbr> <wbr> <wbr> <wbr> <wbr> 2%
Total<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 2013866 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 15733
# echo ::memstat |mdb -k
Page Summary<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> Pages <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> MB <wbr> %Tot
------------<wbr> <wbr> <wbr> <wbr> ---------------- <wbr> ---------------- <wbr> ----
Kernel<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 70542 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 551 <wbr> <wbr> <wbr> 4%
Anon<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 950567 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 7426 <wbr> <wbr> 47%
Exec and libs<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 5965 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 46 <wbr> <wbr> <wbr> 0%
Page cache<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 6219 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 48 <wbr> <wbr> <wbr> 0%
Free (cachelist)<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 978159 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 7641 <wbr> <wbr> 49%
Free (freelist)<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 2414 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 18 <wbr> <wbr> <wbr> 0%
Solaris記憶體管理的一些基本原理
首先,透過在root許可權下執行
# echo ::memstat |mdb -k
Page Summary
------------
Kernel
Anon
Exec and libs
Page cache
Free (cachelist)
Free (freelist)
Total
# echo ::memstat |mdb -k
Page Summary
------------
Kernel
Anon
Exec and libs
Page cache
Free (cachelist)
Free (freelist)