5.5. Tuning Virtual Memory
Virtual memory is typically consumed by processes, file system caches, and the kernel. Virtual memory utilization depends on a number of factors, which can be affected by the following parameters.
- A value from 0 to 100 which 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 physical memory. A low value avoids swapping processes out of memory, which usually decreases latency, at the cost of I/O performance. The default value is 60.
WarningSince RHEL 6.4, setting
swappiness=0more aggressively avoids swapping out, which increases the risk of OOM killing under strong memory and I/O pressure.A low
swappinessvalue is recommended for database workloads. For example, for Oracle databases, Red Hat recommends a
- The minimum number of kilobytes to keep free across the system. This value is used to compute a watermark value for each low memory zone, which are then assigned a number of reserved free pages proportional to their size.
WarningBe cautious when setting this parameter, as both too-low and too-high values can be damaging and break your system.Setting
min_free_kbytestoo low prevents the system from reclaiming memory. This can result in system hangs and OOM-killing multiple processes.However, setting this parameter to a value that is too high (5-10% of total system memory) will cause your system to become out-of-memory immediately. Linux is designed to use all available RAM to cache file system data. Setting a high
min_free_kbytesvalue results in the system spending too much time reclaiming memory.
- Defines a percentage value. Writeout of dirty data begins (via pdflush) when dirty data comprises this percentage of total system memory. The default value is
20.Red Hat recommends a slightly lower value of
15for database workloads.
- Defines a percentage value. Writeout of dirty data begins in the background (via pdflush) when dirty data comprises this percentage of total memory. The default value is
10. For database workloads, Red Hat recommends a lower value of
- Specifies the number of centiseconds (hundredths of a second) dirty data remains in the page cache before it is eligible to be written back to disk. Red Hat does not recommend tuning this parameter.
- Specifies the length of the interval between kernel flusher threads waking and writing eligible data to disk, in centiseconds (hundredths of a second). Setting this to
0disables periodic write behavior. Red Hat does not recommend tuning this parameter.
- Setting this value to
3causes the kernel to drop various combinations of page cache and slab cache.
This is a non-destructive operation. Since dirty objects cannot be freed, running
- The system invalidates and frees all page cache memory.
- The system frees all unused slab cache memory.
- The system frees all page cache and slab cache memory.
syncbefore setting this parameter's value is recommended.
drop_cachesto free memory is not recommended in a production environment.
To set these values temporarily during tuning, echo the desired value to the appropriate file in the proc file system. For example, to set
# echo 50 > /proc/sys/vm/swappiness
To set this value persistently, you will need to use the
sysctlcommand. For further information, refer to the Deployment Guide, available from http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/.