Skip to content

Instantly share code, notes, and snippets.

@YenHub
Created March 31, 2021 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YenHub/d37f0d0826e24bfaa84647666afd6e8c to your computer and use it in GitHub Desktop.
Save YenHub/d37f0d0826e24bfaa84647666afd6e8c to your computer and use it in GitHub Desktop.
Vmmem Eating All Your Memory??

Vmmem Eating All Your Memory??

Simples...

WORKAROUND:

Add the following alias to the tail of ~/.bashrc

# Edit .bashrc (Right click to paste, Ctrl+X to save)
sudo nano ~/.bashrc

# Add the following line:- 
alias drop_cache="sudo sh -c \"echo 3 >'/proc/sys/vm/drop_caches' && swapoff -a && swapon -a && printf '\n%s\n' 'Ram-cache and Swap Cleared'\""

# Then run source ~/.bashrc in your WSL shell to setup the alias
source ~/.bashrc

# Now you can simply run `drop_cache` in the terminal to clear
drop_cache

Following these steps, you may then run the drop_cache command from your WSL Bash Terminal when you need it

Simply run it when memory use creeps, or cron job it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment