You are not logged in.

#1 2011-09-24 14:07:49

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

drop_caches

Have anybody experienced with something like that:

root# echo 0 > /proc/sys/vm/drop_caches
bash: echo: write error: Invalid argument
root#

This seems that after setting drop_caches to any value (the initial is 0) it cannot be restored. More strange - there is no problem to set it to 1 or 2, just 0 is invalid. Could you tell me what is wrong?

Last edited by nbvcxz (2011-09-24 14:08:06)


Lenovo G50 | LXQT-git | compton | conky

Offline

#2 2011-09-24 14:21:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: drop_caches

Offline

#3 2011-09-24 15:01:31

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: drop_caches

drop_caches is a command, not a variable to be set,

drop_caches

Writing to this will cause the kernel to drop clean caches, dentries and
inodes from memory, causing that memory to become free.

To free pagecache:
        echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
        echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
        echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, the
user should run `sync' first.

See, no 0.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#4 2011-09-24 19:50:57

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

Re: drop_caches

Understood karol and fsckd. Thank you for help. My misunderstanding was from: https://wiki.archlinux.org/index.php/Em … pty_caches where author suggests "setting back" drop_caches to 0 (line 5). But now if I am right "0" is just initial (dummy) value and there is no need to set it back to 0.
So in script instead of:

echo 3 > /proc/sys/vm/drop_caches
echo 0 > /proc/sys/vm/drop_caches

it should be something like:

sync
sysctl -w vm.drop_caches=3

Last edited by nbvcxz (2011-09-24 19:52:08)


Lenovo G50 | LXQT-git | compton | conky

Offline

#5 2011-09-24 20:21:35

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: drop_caches

nbvcxz wrote:

it should be something like:

sync
sysctl -w vm.drop_caches=3

Yes, at least that's how I do it:

sync; sysctl -w vm.drop_caches=3

Could you please fix the wiki?

Offline

Board footer

Powered by FluxBB