In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the method of viewing memory commands under Linux, which has a certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
The command to view memory is the free command. The Linux free command shows the usage of system memory, including physical memory, swap memory (swap), and kernel buffer memory.
Course
Under Linux, we often use the top command to view the system process, and top can also display the system memory. Our common tool for viewing content under Linux is the free command.
Memory View Command free under Linux:
To view memory under Linux, we usually use the free command:
$free total used free shared buffers cachedMem: 3266180 3250004 16176 0 110652 2668236 + buffers/cache: 471116 2795064Swap: 2048276 80160 1968116
The following is an explanation for viewing the output of the free command in memory:
Total: the total amount of physical memory. Used: how much has been used. Free: how many are available? Shared: the total amount of memory shared by multiple processes. Buffers/cached: size of the disk cache.
The third line (- / + buffers/cached):
Used: how much has been used. Free: how many are available?
The fourth line does not explain much.
-/ + buffers/cache meaning and difference:
The difference between the used/free of the second line (mem) and the third line (- / + buffers/cache) used/free is from the perspective of usage:
The second line is from the point of view of OS, because OS,buffers/cached belongs to being used, so his available memory is 16176KB, and the used memory is 3250004KB, including + buffers+cached used by + Application (X, oracle,etc) for OS. The third line refers to that from an application point of view, buffers/cached is equal to available for applications, because buffer/cached is designed to improve file read performance, and buffer/cached is quickly recycled when the application needs to use memory.
So from an application perspective, available memory = system free memory+buffers+cached.
As in the above example:
2795064161761106522668236
How memory is swapped
Next, explain when the memory will be swapped and where to swap. When the available memory is less than the rated value, a meeting is held to swap. How to look at ratings:
Cat / proc/meminfo
The output is:
$cat / proc/meminfoMemTotal: 3266180 kBMemFree: 17456 kBBuffers: 111328 kBCached: 2664024 kBSwapCached: 0 kBActive: 467236 kBInactive: 2644928 kBHighTotal: 0 kBHighFree: 0 kBLowTotal: 3266180 kBLowFree: 17456 kBSwapTotal: 2048276 kBSwapFree: 1968116 kBDirty: 8 kBWriteback: 0 kBMapped: 345360 kBSlab : 112344 kBCommitted_AS: 535292 kBPageTables: 2340 kBVmallocTotal: 536870911 kBVmallocUsed: 272696 kBVmallocChunk: 536598175 kBHugePages_Total: 0HugePages_Free: 0Hugepagesize: 2048 kB
The results viewed with free-m:
[root@scs-2 tmp] # free-m total used free shared buffers cachedMem: 3189 3173 16 0 107 2605 Melody + buffers/cache: 460 2729Swap: 2000 78 1921
View the size of the / proc/kcore file (memory image):
$ll-h / proc/kcore-r- 1 root root 4.1G Jun 12 12:04 / proc/kcore
Note:
Measurement of memory consumption
Linux provides us with a convenient way to measure how much memory a process consumes. The / proc directory provides us with all the information. In fact, tools such as top also use this to get the corresponding information.
The memory usage information of the / proc/meminfo machine / proc/pid/maps pid is the process number, which shows the virtual address occupied by the current process. / memory occupied by proc/pid/statm processes $cat / proc/self/statm654 57 44 0 0 334 0
Output interpretation
CPU and CPU0. The meaning of each parameter for each line (in the case of the first behavior example) is:
Parameter interpretation / proc/status
Size (pages) the size of the virtual address space of the task VmSize/4
The size of the physical memory being used by the Resident (pages) application VmRSS/4
Number of Shared (pages) shared pages 0
The size of executable virtual memory owned by the Trs (pages) program VmExe/4
Lrs (pages) the size VmLib/4 of the library that is mapped to the virtual memory space of the task
Drs (pages) program data segment and user mode stack size (VmData+ VmStk) 4
Dt (pages) 04
Check the available memory on the machine
/ proc/28248/ > free
Total used free shared buffers cached
Mem: 1023788 926400 97388 0 134668 503688
-/ + buffers/cache: 288044 735744
Swap: 1959920 89608 1870312
Linux view memory and memory usage summary:
When we look at the machine's free memory through the free command, we find that the value of free is very small. This is mainly because there is an idea in linux that memory is not used in vain, so it tries to cache and buffer some data as much as possible to facilitate next use. But in fact, this memory can also be used immediately.
So free memory = free+buffers+cached=total-used
Thank you for reading this article carefully. I hope the editor will share what the method of viewing memory commands under Linux is helpful to everyone. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.