3

I have the following shell script that I've been using in previous versions of Ubuntu (<= 11.04) to clear memory cache and it has worked fine:

sudo sync && sudo sysctl -w vm.drop_caches=3 && sudo sysctl -w vm.drop_caches=0

I have a new clean install of 11.10 with 3.0.0-12-generic kernel and I get the following error when running the same script script:

vm.drop_caches = 3

error: "Invalid argument" setting key "vm.drop_caches"

Community
  • 1
  • 1
wahalulu
  • 1,447
  • 2
  • 17
  • 23

1 Answers1

1

Documentation/sysctl/vm.txt:

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

You can't setting this to zero.

rcvoid
  • 69
  • 2
  • thanks, I'll try it. Did you try with vm.drop_caches=0? That is specifically where I was getting the error. 3 worked fine. – wahalulu Nov 09 '11 at 17:30
  • 6
    My `/proc/sys/vm/drop_caches` had `0` by default. I set it to 3, 2, 1, now can't return it to default state. – Nakilon Oct 23 '17 at 04:58