Project

General

Profile

Actions

Purge Linux Cache Memory » History » Revision 1

Revision 1/2 | Next »
Alexis Jeandet, 06/11/2013 08:53 PM


Purge Linux Cache Memory

Sometime the linux kernell uses a lot of cache memory, it can prevent you from allocating memory in your programs. To solve this issue, one solution is to periodically force the kernell to flush its caches buffers.

mkdir -p /opt/scripts
echo "#!/bin/bash" >  /opt/scripts/clearcachemem.sh
echo "sync; echo 3 > /proc/sys/vm/drop_caches" >>  /opt/scripts/clearcachemem.sh
chmod +x /opt/scripts/clearcachemem.sh # make it executable

Then edit cron config with:

sudo crontab -e
# enter insert mode with "i" 
# paste "0 0 * * * /opt/scripts/clearcachemem.sh" 
# exit with "echap" key then type ":wq" then "return" key

Updated by Alexis Jeandet about 11 years ago · 1 revisions

Also available in: PDF HTML TXT