DEV Community

Claudio Davi
Claudio Davi

Posted on

Reducing VSCode Memory Consumption

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
  }
Enter fullscreen mode Exit fullscreen mode

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
  },
Enter fullscreen mode Exit fullscreen mode

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
  }

Enter fullscreen mode Exit fullscreen mode

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
  },

Enter fullscreen mode Exit fullscreen mode

Do you have any more tips that can improve VSCode performance? Share with us!

Top comments (24)

Collapse
 
joaomoreno profile image
João Moreno

Hey there. VS Code dev here. A few comments:

  • Disabling telemetry does absolutely nothing to reduce memory.
  • There is no search indexing at all. We use ripgrep to provide fast search. Adding stuff to search.exclude reduces no memory at all.
  • Creating workspaces is actually allocating more memory than simply opening folders.

The best thing you can do to reduce memory consumption in VS Code is: install less extensions.

Collapse
 
claudiodavi profile image
Claudio Davi

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!!

Collapse
 
ekoetsjarjan profile image
Edward Koetsjarjan

is it possible to see what extensions uses how much memory, the easy way?
was looking but not found any , thank you

Collapse
 
renanprometheusarch profile image
Renan Moura

kkkkkkkkkkkkkkk i dont think so man ... we also write some shit code sometimes ... kkkkk dont be so silly kkkk

Collapse
 
arthurfiorette profile image
Arthur Fiorette

Mano, rir com kkk fora do brasil é errado demais ausdhauishdiashd

Collapse
 
orenmizr profile image
Oren Mizrahi

if everyone removed their telemetry - vscode would be less effective. it helps the VSC team counter issues with the product. i think.

Collapse
 
mohannadk28 profile image
Mohannadk28

if someone got an issue he will probably just report it in the GitHub issues page

Collapse
 
claudiodavi profile image
Claudio Davi

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!

Collapse
 
jsardev profile image
Jakub Sarnowski

My tip would be: delete all useless or redundant extensions that you're not actually using 😄

Collapse
 
msfjarvis profile image
Harsh Shandilya

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!

Collapse
 
claudiodavi profile image
Claudio Davi

I'm glad I could help!

Collapse
 
adilimudassir profile image
Mudassir Adili

Thank you for this. This memory consumption issue has been a pain for me

Collapse
 
claudiodavi profile image
Claudio Davi

It is a pain to us all. Glad I could help!

Collapse
 
zed_m profile image
Amine Hammou

thank you

Collapse
 
sskanishk profile image
Kanish Malviya

Use SublimeText

Collapse
 
codestuff2 profile image
Adam Whitlock

This is a great little collection of tips. Thanks for writing!

Collapse
 
aleccool213 profile image
Alec Brunelle

Was waiting for a long time for this kind of post! Amazing!

Collapse
 
krlyric profile image
Katherine

great topic! thanks