sh 强制删除页面缓存并触发Linux MM的内存页面压缩程序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 强制删除页面缓存并触发Linux MM的内存页面压缩程序相关的知识,希望对你有一定的参考价值。
#!/bin/sh
set -u
NUMA_BEFORE=`numactl -H | grep free:`
SLAB_BEFORE=`grep Normal /proc/buddyinfo`
printf "Dropping page cache..."
sysctl -qw vm.drop_caches=1
echo
printf "Defragmenting memory pages..."
sysctl -qw vm.compact_memory=1
echo
NUMA_AFTER=`numactl -H | grep free:`
SLAB_AFTER=`grep Normal /proc/buddyinfo`
echo
echo "Free memory per NUMA domain:"
echo "Before: " ${NUMA_BEFORE} | tr -s ' ' '\t'
echo "After: " ${NUMA_AFTER} | tr -s ' ' '\t'
echo
echo "Slab Allocator status:"
echo "Before: " ${SLAB_BEFORE} | tr -s ' ' '\t'
echo "After: " ${SLAB_AFTER} | tr -s ' ' '\t'
以上是关于sh 强制删除页面缓存并触发Linux MM的内存页面压缩程序的主要内容,如果未能解决你的问题,请参考以下文章