Visual Studio 2015 JavaScript Memory Leak? Solved.

If you are someone who:

  • Has been using Visual Studio 2015
  • Working with fairly large projects containing Angular JS code
  • Has been having crashes or low memory warnings when working in VS on that code

There is good news - the cause of the last bullet has been identified and a fix is on the way in the next update to Visual Studio 2015. And there is a pretty easy workaround to eradicate the problem until then.

I've been working on a number of projects since the Fall 2015 that are all central around various SPA technologies including Aurelia, Angular, and Cordova. I kept asking other MVPs, RDs, and friends who are .NET and Web developers about how Visual Studio 2015 seemed really unstable and crashed on me all the time, asking if they had seen the same thing. And most had not, or had only occassionally seen that kind of thing. For me it was all day every day at least 5-10 crashes a day. It was driving me crazy. So I reached out to the VS team and described my problems and that they seemed related to the JS Language Service. I had not made the correlation that it was Angular JS code only that was making it happen.

The folks on the team I worked with were awesome in terms getting on it quickly and trying hard to find the problem. Even for me it seemed to happen in some solutions and not in others. But since I had two solutions where I could 100% repro on any of my machines, they were able to remote in, do some debugging and help isolate the problem. And even once they discovered the correlation with Angular I could still open some (smaller-ish) Angular projects and work with them without the memory leak occuring. But for those that triggered it, it was pretty obvious - open a JS file with Angular code in it, and watch the memory progressively run away in Task manager. Then it seemed the problem was fixed by removing the angular intellisense file, but not on my machines. Finally we tracked it down to Web Essentials could also add some stuff to your machine that even if you uninstalled it did not clear the problem.

So if you have been feeling any of this pain, here is the workaround until the next update to VS comes around with a fix. All you need to do is:

  1. Uninstall Web Essentials if you have it installed. (I know, Mads: this makes me weep)
  2. Go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\JavaScript\References and delete or rename your angular.intellisense.js file.
  3. Delete or move the C:\Users\[username]\AppData\Local\Microsoft\FSPCache folder.

Done. And life resumes to the rock solid, productive, wonderful IDE that we have all known and loved for over a decade.

Big thanks to the VS JS Language team for their persistence and responsiveness on working to track this one down: Ed Maurer and Akrosh Gandhi in particular from my interactions for getting the right resources on the problem and tracking it down to root cause with a fix, respectively, but know there were a cast of others involved as well.