Clear memory cache on your Linux server

There may be a time that you wish to clear a Memory on your server. Normally you do not want to fiddle with it so do it only you are sure that it is necessary and that it would not affect your server’s performance. For this we can use sysctl command which allows linux admins to configure kernel parameters at runtime.

This command will clear pagecache:

/sbin/sysctl vm.drop_caches=1

To clear dentries and inodes you can use:

/sbin/sysctl vm.drop_caches=2

To free memory of the all above use a following command:

/sbin/sysctl vm.drop_caches=3

What the above commands will do is that they will sync your memory and edit a following file with appropriate number entry. :


Do not edit this file directly !

Use top utility to see whether you successfully freed your memory.

Leave a Reply