linux View memory usage
When optimizing the Linux system, physical memory is the most important aspect. Naturally, Linux also provides many methods to monitor the usage of precious memory resources. The following list details the various methods of viewing memory usage through view tools or command lines under Linux systems.
Recommended: [Linux video tutorial]
1. /proc/meminfo
The easiest way to check RAM usage The method is through /proc/meminfo. This dynamically updated virtual file is actually a combination display of many other memory-related tools (such as: free / ps / top), etc. /proc/meminfo lists all the memory usage you want to know about. The memory usage information of the process can also be viewed through /proc/
$ cat /proc/meminfo
2. atop
The atop command is a terminal environment monitoring command. It shows a combination of various system resources (CPU, memory, network, I/O, kernel) and is color-coded under high load conditions.
$ sudo atop
3. free
The free command is a quick way to view memory usage. It is an overview of the information collected by /proc/meminfo.
$ free -h
4. GNOME System Monitor
GNOME System Monitor is a view tool that displays the usage of CPU, memory, swap area and network in the recent period. It also provides a way to view CPU and memory usage.
$ gnome-system-monitor
5. htop
The htop command displays the real-time memory usage of each process. It provides reports on the resident memory size of all processes, total program memory size, shared library size, etc. The list can be scrolled horizontally and vertically.
$ htop
6. KDE System Monitor
The functions are the same as the GENOME version introduced in 4.
$ ksysguard
7. memstat
memstat is a command that effectively identifies the virtual memory usage of executable(s), process(es) and shared libraries. Given a process ID, memstat can list the executable files, data and shared libraries associated with this process.
$ memstat -p <PID>
8. nmon
nmon is a system benchmark testing tool based on ncurses. It can monitor CPU, memory, I/O, file system and network resources, etc. interactive mode. For memory usage, it can display total/remaining memory, swap space and other information in real time.
$ nmon
9. ps
ps command can display the memory usage of each process in real time. Reported memory usage information includes %MEM (percent of physical memory used), VSZ (total amount of virtual memory used), and RSS (total amount of physical memory used). You can use the "-sort" option to sort processes, for example by RSS:
$ ps aux --sort -rss
10. smem
The smem command allows you to count statistics based on /proc information Memory usage of different processes and users. Analysis of memory usage can export charts (such as bar charts and pie charts).
$ sudo smem --pie name -c "pss"
11. The top
top command provides real-time resource usage statistics of running programs. You can sort based on memory usage and size.
$ top
12. vmstat
The vmstat command displays real-time and average statistics, covering CPU, memory, I/O, etc. For example, memory status not only displays physical memory, but also counts virtual memory.
$ vmstat -s
The above is the detailed content of Check memory usage in linux. For more information, please follow other related articles on the PHP Chinese website!