In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to judge how much memory is installed and used in the Linux system. It is very detailed and has a certain reference value. Interested friends must read it!
Before we begin, let's review some of the basics. Physical and virtual memory are not the same thing. The latter includes disk space configured as swap space. Swap space may include partitions specifically set aside for this purpose, as well as files created to increase available swap space when creating a new swap partition is not feasible. Some Linux commands provide information about both.
When physical memory is full, swap space expands memory by providing disk space that can be used to store inactive pages in memory.
/ proc/kcore is a file that plays a role in memory management. This file looks like an ordinary file (although very large), but it doesn't take up any space. It is a virtual file just like any other file under / proc.
$ls-l / proc/kcore-r-. 1 root root 140737477881856 Jan 28 12:59 / proc/kcore
Interestingly, the two systems queried below do not have the same amount of memory installed, but the / proc/kcore is the same size. The first system has 4 GB of memory installed, while the second system has 6 GB installed.
System1 $ls-l / proc/kcore-r-. 1 root root 140737477881856 Jan 28 12:59 / proc/kcoresystem2 $ls-l / proc/kcore-r- 1 root root 140737477881856 Feb 5 13:00 / proc/kcore
An unreliable explanation is that this file represents the size of available virtual memory (maybe 4 KB), and if so, the virtual memory of these systems is 128TB! This number seems to represent how much memory a 64-bit system can address, rather than how much memory is available on the current system. It's easy to calculate 128 TB and this file size plus 4 KB on the command line.
$expr 1024\ * 1024\ * 1024\ * 1024\ * 128140737488355328$ expr 1024 + 4096140737488359424
Another more humane command to check memory is free. It gives an easy-to-understand memory report.
$free total used free shared buff/cache availableMem: 6102476 812244 4090752 13112 1199480 4984140Swap: 2097148 0 2097148
Using the-g option, free returns the result in GB units.
$free-g total used free shared buff/cache availableMem: 5 0 3 0 1 4Swap: 1 0 1
Using the-t option, free displays the same value as when there is no additional option (don't interpret the-t option as TB) and adds an additional row of total data at the bottom of the output.
$free-t total used free shared buff/cache availableMem: 6102476 812408 4090612 13112 1199456 4983984Swap: 2097148 0 2097148Total: 8199624 812408 6187760
Of course, you can choose to use both options at the same time.
$free-tg total used free shared buff/cache availableMem: 5 0 30 1 4Swap: 1 0 1Total: 7 0 5
If you try to use this report to explain "how much memory is installed on this system?" You may be disappointed. The above report is the result of running on the system with 6 GB memory mentioned earlier. This is not to say that the result is wrong, this is the system's view of its available memory.
The free command also provides the option to refresh the display every X seconds (X is 10 in the example below).
Free-s 10 total used free shared buff/cache availableMem: 6102476 812280 4090704 13112 1199492 4984108Swap: 2097148 0 2097148 total used free shared buff/cache availableMem: 6102476 812260 4090712 13112 1199504 4984120Swap: 2097148 0 2097148
Using the-l option, the free command provides information about high and low memory usage.
$free-l total used free shared buff/cache availableMem: 6102476 812376 4090588 13112 1199512 4984000Low: 6102476 2011888 4090588High: 00 0Swap: 2097148 0 2097148
Another option for viewing memory is the / proc/meminfo file. Like / proc/kcore, this is also a virtual file that provides reports on how much memory is installed or used and how much memory is available. Obviously, free memory and available memory are not the same thing. MemFree appears to represent unused RAM. MemAvailable is an estimate of the memory available when starting a new program.
$head-3 / proc/meminfoMemTotal: 6102476 kBMemFree: 4090596 kBMemAvailable: 4984040 kB
If you only want to view memory totals, you can use one of the following commands:
$awk'/ MemTotal/ {print $2}'/ proc/meminfo6102476 $grep MemTotal/ proc/meminfoMemTotal: 6102476 kB
DirectMap divides memory information into several categories.
$grep DirectMap / proc/meminfoDirectMap4k: 213568 kBDirectMap2M: 6076416 kB
DirectMap4k represents the memory size mapped to standard 4k pages, while DirectMap2M shows the memory size of pages mapped to 2 MB.
The getconf command will provide more information than most of us want to see.
$getconf-a | moreLINK_MAX 65000_POSIX_LINK_MAX 65000MAX_CANON 255_POSIX_MAX_CANON 255MAX_INPUT 255_POSIX_MAX_INPUT 255NAME_MAX 255_POSIX_NAME_MAX 255PATH_MAX 4096_POSIX_PATH_MAX 4096PIPE_BUF 4096_POSIX_PIPE_BUF 4096SOCK_MAXBUF_POSIX_ASYNC_IO_POSIX_CHOWN_RESTRICTED 1_POSIX_NO_TRUNC 1_POSIX_PRIO_IO_POSIX_SYNC_IO_POSIX_VDISABLE 0ARG_MAX 2097152ATEXIT_MAX 2147483647CHAR_BIT 8CHAR_MAX 127Muhami Moremuri-
Use a command similar to the following to simplify its output to the specified content, and you will get the same results as the other commands mentioned earlier.
$getconf-a | grep PAGES | awk 'BEGIN {total = 1} {if (NR = = 1 | | NR = = 3) total * = $NF} END {print total / 1024 "kB"}' 6102476 kB
The above command calculates memory by multiplying the header line of the output below and the value of the last line.
PAGESIZE 4096
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.