问题:
当数据收集进程占用内存的20%时,其余的内存被PageCache填充,这会导致问题。
sysctl -w vm.drop_caches=1
我在Ubuntu server 20上运行程序
如何禁用硬盘/整个系统上的页面缓存?
>>> free
total used free shared buff/cache available
Mem: 3981820 202180 3600504 852 179136 3565116
Swap: 0 0 0
>>>free
total used free shared buff/cache available
Mem: 3981820 202336 3593204 852 186280 3561364
Swap: 0 0 0
>>>free
total used free shared buff/cache available
Mem: 3981820 203132 3505208 852 273480 3547512
Swap: 0 0 0
Buff/cache继续增长,直到我刷新内存
>>>sudo lshw -C memory
*-firmware
description: BIOS
vendor: Amazon EC2
physical id: 0
version: 1.0
date: 10/16/2017
size: 64KiB
capacity: 64KiB
capabilities: pci edd acpi virtualmachine
*-memory
description: System memory
physical id: 1
size: 4GiB
>>>sysctl vm.swappiness
vm.swappiness = 60
答案1:
注意: buff/cache是磁盘/文件缓存,应该很大。
你没有swap!
total used free shared buff/cache available
Mem: 3981820 202180 3600504 852 179136 3565116
Swap: 0 0 0
创建一个/swapfile。
sudo swapoff -a # turn off swap
sudo rm -i /swapfile # remove old /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile # set proper file protections
sudo mkswap /swapfile # init /swapfile
sudo swapon /swapfile # turn on swap
free -h # confirm 4G RAM and 4G swap
在/etc/fstab中确认此行,
/swapfile none swap sw 0 0
reboot # reboot and verify operation
答案2:
要禁用写入缓存,请尝试以下操作:
编辑/etc/hdparm.conf。
取消注释这两行中的第二行,使它如下所示:
# -W Disable/enable the IDE drive's write-caching feature
write_cache = off
编辑/etc/hdparm.conf。
# -W Disable/enable the IDE drive's write-caching feature
# write_cache = off
答案3
安装nocache软件包:
sudo apt-get install nocache
然后使用nocache命令运行进程:
nocache whatever
相关文章