Press "Enter" to skip to content

How to clear swap memory in Linux Command

Do you want to clear swap memory in Linux Command?

Writing the appropriate value to the file /proc/sys/vm/drop_caches causes the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

Here’s are the easy method to clear swap memory in Linux Command:

1. In order to clear PageCache only run:

# sync; echo 1 > /proc/sys/vm/drop_caches

2. In order to clear dentries (Also called as Directory Cache) and inodes run:

# sync; echo 2 > /proc/sys/vm/drop_caches

3. In order to clear PageCache, dentries and inodes run:

# sync; echo 3 > /proc/sys/vm/drop_caches