TypeScript: Visual Studio 2015 Out of Memory Crash (reproducible)

TypeScript Version: 2.3.3 (VS plugin) Environment: Visual Studio 2015 update 3, Windows 7 Project Type: tsconfig.json (relevant part…)

  "compilerOptions": {
    "lib": [ "es2017", "dom", "dom.iterable", "webworker" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "skipDefaultLibCheck": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  // ...

Project Info TFS for SCM, mixed code project (TS and C#)

tsc --diagnostics -w: 171k lines, 580 files, ~800 MB mem used, ~8 sec Check time

Visual Studio runs out of memory and crashes frequently. The behavior varies and falls into one of these cases:

  • VS2015 closes without warning and a small popup with the message ‘Hard Error’ and an OK button is displayed
  • VS2015 freezes and ‘(not responding)’ is appended to the title bar, clicking on the window or trying to close it causes the standard Windows error report popup to be displayed
  • VS2015 displays a ‘Visual Studio has suspended some advanced features to improve performance.’ message along the top of text editor window and VS crashes 3-10 mins later

The issue has grown worse over the last ~6 months as our team has progressively upgraded from TypeScript 2.0 - 2.3 and as our codebase has grown. This week VS2015 has been crashes every 45 - 60 mins while editing TS files. I’ve been monitoring devenv.exe via Task Manager and the crashes always occur when it reaches ~3.2 GBs of memory usage.

These crashes can be reproduced my me and a coworker with the proprietary codebase we work on (I also work on several small open source TypeScript projects and have not had VS2015 issues with those). I don’t think I can condense the issue down to a non-proprietary repo that I’d be allowed to share with you guys so I’d love some guidance on debugging this from my end.

I have logs from running VS with logging enabled via devenv.exe /log path and would be happy to provide those logs if requested.

I attempted to follow the Dev Mode in Visual Studio wiki article several weeks ago, but couldn’t get it working and found issue https://github.com/Microsoft/TypeScript/issues/14928 which indicates that dev mode no longer works.

Also tried VS Code a few weeks ago and tsserver does not have the same memory issue as VS2015, but VS Code doesn’t have all the features I’ve grown to love in VS2015 so I’d like to stick with VS2015 and get this issue figure out.

I looked around this repository and couldn’t find anything that looked like the code for the VS plugin. I’d love if we could revisit this thought https://github.com/Microsoft/TypeScript/issues/2656#issuecomment-90668363.

I’m ready to devote my own time to resolving this issue as it’s seriously affecting my productivity! Any suggestions on what I can do for you guys to help track down this issue?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 18 (9 by maintainers)

Most upvoted comments

On a side note, I’ve often noticed that the VS plugin updates are released several days or 1-2 weeks after a release here on github. Is there some type of beta channel for Visual Studio where I can get patches (like 2.4.2) quicker?

we release the TS compiler/tsserver as an out of band release. you can get any version from https://www.microsoft.com/en-us/download/details.aspx?id=55258. TS 2.5-rc is out today, give it a try.

For any future viewers of this issue, VS2017 completely changes the way TypeScript is handled. If you open task manager on Windows and watch your list of processes when you load a TypeScript project in VS2017, you’ll notice that 3 node.js processes start up, these appear to run compilation and error checking/auto-complete services for VS2017 the say way VS Code handles TypeScript language services. The memory leak I was experiencing with TypeScript projects in VS2015 does not appear to occur when using node.js and tsserver.js for language services so I guess the solution is to upgrade to VS2017 (which, unfortunately, often isn’t an option in corporate settings)…

Interestingly, I just got pointed to this bug/description, which sounds quite likely (though I still don’t understand why I’m not seeing it, but we may have different project structure/settings which comes into play): https://github.com/Microsoft/TypeScript/issues/16610#issuecomment-312538922

There are two ways we can see if this is the issue:

  1. Switch on logging and see if you see the same exception outlined in the bug.
  2. Update the tsserver.js file with the fixed version and see if that resolves the problem.

If you want to enable logging, set an environment var before launching VS as per these instructions

If you want to try the fix, (temporarily) backup the tsserver.js file under ““C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.4\tsserver.js””, and replace it with the version from https://raw.githubusercontent.com/Microsoft/TypeScript/release-2.4/lib/tsserver.js .

Let me know if either of these point to this as being the root cause.

Yeah, Screen2Gif is a handy tool 😃

If everything else is functioning fine, the only reason I can think is if the options have it turned off. Could you check under Tools / Options the values you have for “Text Editor / All languages / General / Auto-list members”, and “Text Editor / JavaScript/TypeScript / General / Auto-list members”. If I switch these off, I get the behavior you describe. (And these settings can roam across installs when you sign-in, which is why you’d see it even on a clean install).

The editor doesn’t automatically pop-up a list of types once in a type position, but once you start typing, you should get a completion list of all identifiers (including types) in scope, as shown below for a var or param type. Do you see similar behavior? That is the current design. (There are a number of places where it could filter to just the semantically valid items, but that work hasn’t been done yet).

typecompletions