Project

General

Profile

Purge Linux Cache Memory » History » Version 1

Alexis Jeandet, 06/11/2013 08:53 PM

1 1 Alexis Jeandet
h1. Purge Linux Cache Memory
2
3
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. 
4
5
<pre><code class="bash">
6
mkdir -p /opt/scripts
7
echo "#!/bin/bash" >  /opt/scripts/clearcachemem.sh
8
echo "sync; echo 3 > /proc/sys/vm/drop_caches" >>  /opt/scripts/clearcachemem.sh
9
chmod +x /opt/scripts/clearcachemem.sh # make it executable
10
</code></pre>
11
12
Then edit cron config with:
13
14
<pre><code class="bash">
15
sudo crontab -e
16
# enter insert mode with "i"
17
# paste "0 0 * * * /opt/scripts/clearcachemem.sh"
18
# exit with "echap" key then type ":wq" then "return" key
19
</code></pre>