7.5. Configuring System Memory Capacity
/procfile system. Once you have determined the values that produce optimal performance for your use case, you can set them permanently by using the
# echo 1 > /proc/sys/vm/overcommit_memory
/etc/sysctl.confthen run the following command:
# sysctl -p
7.5.1. Virtual Memory Parameters
/proc/sys/vmunless otherwise indicated.
- A percentage value. When this percentage of total system memory is modified, the system begins writing the modifications to disk with the
pdflushoperation. The default value is
- A percentage value. When this percentage of total system memory is modified, the system begins writing the modifications to disk in the background. The default value is
- Defines the conditions that determine whether a large memory request is accepted or denied.The default value is
0. By default, the kernel performs heuristic memory overcommit handling by estimating the amount of memory available and failing requests that are too large. However, since memory is allocated using a heuristic rather than a precise algorithm, overloading memory is possible with this setting.When this parameter is set to
1, the kernel performs no memory overcommit handling. This increases the possibility of memory overload, but improves performance for memory-intensive tasks.When this parameter is set to
2, the kernel denies requests for memory equal to or larger than the sum of total available swap space and the percentage of physical RAM specified in
overcommit_ratio. This reduces the risk of overcommitting memory, but is recommended only for systems with swap areas larger than their physical memory.
- Specifies the percentage of physical RAM considered when
overcommit_memoryis set to
2. The default value is
- Defines the maximum number of memory map areas that a process can use. The default value (
65530) is appropriate for most cases. Increase this value if your application needs to map more than this number of files.
- Specifies the minimum number of kilobytes to keep free across the system. This is used to determine an appropriate value for each low memory zone, each of which is assigned a number of reserved free pages in proportion to their size.
WarningExtreme values can damage your system. Setting
min_free_kbytesto an extremely low value prevents the system from reclaiming memory, which can result in system hangs and OOM-killing processes. However, setting
min_free_kbytestoo high (for example, to 5–10% of total system memory) causes the system to enter an out-of-memory state immediately, resulting in the system spending too much time reclaiming memory.
- In the event that the system runs out of memory and the
panic_on_oomparameter is set to
oom_killerfunction kills processes until the system can recover, starting from the process with the highest
oom_adjparameter helps determine the
oom_scoreof a process. This parameter is set per process identifier. A value of
oom_killerfor that process. Other valid values are from
NoteProcesses spawned by an adjusted process inherit the
oom_scoreof the process.
- The swappiness value, ranging from
100, controls the degree to which the system favors anonymous memory or the page cache. A high value improves file-system performance while aggressively swapping less active processes out of RAM. A low value avoids swapping processes out of memory, which usually decreases latency at the cost of I/O performance. The default value is
swappiness==0will very aggressively avoids swapping out, which increase the risk of OOM killing under strong memory and I/O pressure.
7.5.2. File System Parameters
/proc/sys/fsunless otherwise indicated.
- Defines the maximum allowed number of events in all active asynchronous input/output contexts. The default value is
65536. Modifying this value does not pre-allocate or resize any kernel data structures.
- Determines the maximum number of file handles for the entire system. The default value on Red Hat Enterprise Linux 7 is the maximum of either
8192, or one tenth of the free memory pages available at the time the kernel starts.Raising this value can resolve errors caused by a lack of available file handles.
7.5.3. Kernel Parameters
/proc/sys/kernel/directory, can be calculated by the kernel at boot time depending on available system resources.
- Defines the maximum allowable size in bytes of any single message in a message queue. This value must not exceed the size of the queue (
msgmnb). To determine the current
msgmaxvalue on your system, use:
# sysctl kernel.msgmax
- Defines the maximum size in bytes of a single message queue. To determine the current
msgmnbvalue on your system, use:
# sysctl kernel.msgmnb
- Defines the maximum number of message queue identifiers, and therefore the maximum number of queues. To determine the current
msgmnivalue on your system, use:
# sysctl kernel.msgmni
- Defines the total amount of shared memory pages that can be used on the system at one time. A page is 4096 bytes on the AMD64 and Intel 64 architecture, for example.To determine the current
shmallvalue on your system, use:
# sysctl kernel.shmall
- Defines the maximum size (in bytes) of a single shared memory segment allowed by the kernel. To determine the current
shmmaxvalue on your system, use:
# sysctl kernel.shmmax
- Defines the system-wide maximum number of shared memory segments. The default value is
4096on all systems.
- Defines the system-wide maximum number of threads available to the kernel at one time. To determine the current
threads-maxvalue on your system, use:
# sysctl kernel.threads-maxThe default value is the result of:
mempages / (8 * THREAD_SIZE / PAGE SIZE )The minimum value is