Reducing VSCode Memory Consumption
Claudio Davi
Posted on June 19, 2019
How to reduce VSCode memory usage
I've been using VSCode for quite a while now and one of the most annoying things that I have noticed is how much memory it uses, specially in comparison with Sublime Text.
I will present you a few tips that I have found to at least make it usable for big projects.
Disclaimer: I mostly use Python, therefore I'm sure that you will find a lot more options to optimize for Javascript or your preferred language.
Most of the tips below must be placed into your user settings (JSON)
Telemetry
First, did you know that VSCode sends data to Microsoft about it's usage?
If you want to turn it off is quite simple, place
"telemetry.enableTelemetry": false
into your configurations and you are all set.
Search Indexing
Search is one of the most memory consuming activity VSCode does. It has to keep an index of all your files and their contents. You probably don't want to search inside your node_modules/ or env/ folder right?
I have had this problem before and I don't know if they come disabled by default now, but it is on my config file so here it goes:
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/env": true,
"**/venv": true
}
File Watcher
The file watcher is used to detect changes in your working files and folders.
If you are like me and every new package you have to pip | npm install
it on the fly you probably have a lot of changes in your secondary files and folders.
So we are going to disable the watcher for those folders and whatever else we don't want to follow, like our git/objects folder.
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/env/**": true,
"**/venv/**": true,
"env-*": true
},
Organizing your Explorer
Ok, now we have optimized for performance, now we want to optimize for productivity. One of the most important things to do is to reduce the clutter in your workspace.
To do that we are going to remove files from the Explorer tab. Why? We don't really want to see files that we are not going to work with.
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/.vscode": true,
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/node_modules": true,
"venv": true,
"*.sublime-*": true,
"env*": true
}
That will leave you with most of the clutter out of sight. Which is Great!
Extra Tips
A few extra tips to help you:
Workspaces
Workspaces are great, create several of them. I always have a few instances of VSCode open for the same project, if you are doing Full-Stack use one for back-end and another for front-end development. If you, like me, are building microservices you can use one workspace for each service. You are going to see how clean it all becomes.
Extensions
Keep the minimum amount of extensions that you can possibly have, most of them are not optimized. Keep what you use daily and disable or uninstall the others. I go through my extensions once a month and do a Marie-Kondo-style cleanup.
Full Script
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/.vscode": true,
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/node_modules": true,
"node_modules": true,
"venv": true,
"*.sublime-*": true,
"env*": true
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/env": true,
"**/venv": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/env/**": true,
"**/venv/**": true,
"env-*": true
},
Do you have any more tips that can improve VSCode performance? Share with us!
Posted on June 19, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.