程式扎記: [Linux 文章收集] Linux Check Memory Usage

標籤

2012年5月16日 星期三

[Linux 文章收集] Linux Check Memory Usage

Preface : 
How do I check used and free RAM memory usage under Linux operating systems using command line and GUI tools? 

Linux comes with different set of commands to check memory usage. The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity. Finally, you can use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. 

free command : 
第一個要介紹的是 free 命令. 透過它你可以知道記憶體使用量, 總記憶體大小等資訊 : 
- Display free memory size in MB: 
 

- Displays a line containing the totals memory in MB: 
 

vmstat command : 
如果你想要動態的瞭解一下系統資源的運作,那麼這個 vmstat 就可以派上用場!它可以偵測『 CPU / 記憶體 / 磁碟輸入輸出狀態 』等等,如果你想要瞭解一部繁忙的系統到底是哪個環節最累人, 可以使用這個命令分析看看 : 
 

底下為顯示 items 說明 : 
- Procs 
r: The number of processes waiting for run time.
b: The number of processes in uninterruptable sleep.
w: The number of processes swapped out but otherwise runnable. This field is calculated, but Linux never desperation swaps.

- Memory 
swpd: the amount of virtual memory used (kB).
free: the amount of idle memory (kB).
buff: the amount of memory used as buffers (kB).

- Swap 
si: Amount of memory swapped in from disk (kB/s).
so: Amount of memory swapped to disk (kB/s).

- IO 
bi: Blocks sent to a block device (blocks/s).
bo: Blocks received from a block device (blocks/s).

- System 
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

top command : 
相對於 ps 是擷取一個時間點的程序狀態, top 則可以持續偵測程序運作的狀態 : 
 
(在 console 執行 top 命令

/proc/meminfo : 
如果你僅是要記憶體的相關資訊, 你可以 cat /proc/meminfo : 
 

Reference : 
Blog : Linux Check Memory Usage 
Blog : Linux – How to check memory usage 
鳥哥 Linux 私房菜 > 程序管理 > free : 觀察記憶體使用情況 
鳥哥 Linux 私房菜 > 程序管理 > vmstat : 偵測系統資源變化

沒有留言:

張貼留言

網誌存檔

關於我自己

我的相片
Where there is a will, there is a way!