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!
Top comments (25)
Hey there. VS Code dev here. A few comments:
search.exclude
reduces no memory at all.The best thing you can do to reduce memory consumption in VS Code is: install less extensions.
Hi, thanks for the heads-up, about the telemetry i know it does not affect memory consumption, but I mentioned I could include as a tip for other devs that don't like sharing data.
Great thing that search doesn't index I didn't know that! But removing folders for search greatly improves user experience during search.
For workspaces, I'll give it a go then. Thank you for the tip!!
is it possible to see what extensions uses how much memory, the easy way?
was looking but not found any , thank you
kkkkkkkkkkkkkkk i dont think so man ... we also write some shit code sometimes ... kkkkk dont be so silly kkkk
Mano, rir com kkk fora do brasil é errado demais ausdhauishdiashd
watchExlude setting is working
if everyone removed their telemetry - vscode would be less effective. it helps the VSC team counter issues with the product. i think.
Yeah, I do believe so. But most devs I know are quite savvy about sharing data, so I included this just to warn people that it does share and there's a way to disable it!
if someone got an issue he will probably just report it in the GitHub issues page
My tip would be: delete all useless or redundant extensions that you're not actually using 😄
Thank you for this. This memory consumption issue has been a pain for me
It is a pain to us all. Glad I could help!
Just implemented this on my laptop and memory consumption has gotten so much better! Even things like searching are significantly faster now. Thanks a lot for sharing!
I'm glad I could help!
thank you
Use SublimeText
This is a great little collection of tips. Thanks for writing!
Was waiting for a long time for this kind of post! Amazing!
great topic! thanks