Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio 2015 Out of Memory Crash (reproducible) #17569

Closed
TeamworkGuy2 opened this issue Aug 2, 2017 · 18 comments
Closed

Visual Studio 2015 Out of Memory Crash (reproducible) #17569

TeamworkGuy2 opened this issue Aug 2, 2017 · 18 comments
Assignees
Labels
Fixed A PR has been merged for this issue Needs More Info The issue still hasn't been fully clarified Visual Studio Integration with Visual Studio

Comments

@TeamworkGuy2
Copy link

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 #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 #2656 (comment).

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?

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Visual Studio Integration with Visual Studio labels Aug 2, 2017
@DanielRosenwasser DanielRosenwasser added Needs More Info The issue still hasn't been fully clarified and removed Bug A bug in TypeScript labels Aug 2, 2017
@billti
Copy link
Member

billti commented Aug 2, 2017

I don't suppose you have a machine with either a) VS 2017 or b) TypeScript 2.4 (or preferably a VS 2017 machine with TS 2.4) to see if this issue still occurs? One of the most useful pieces of info before we investigate further is to know if we've already fixed it ;-)

@TeamworkGuy2
Copy link
Author

I'll see what I can do, I'm not sure if the project will run in VS 2017 community edition (we only have enterprise licenses for VS 2015), but I'll give it a try and report back.

@TeamworkGuy2
Copy link
Author

TeamworkGuy2 commented Aug 3, 2017

@billti & @bowdenk7
VS 2017 is installed - Version 15.2 (26530.16)
I installed TypeScript 2.4.1 from the plugin download page and confirmed that 2.4 was selected in Tools > Options > Text Editor > JavaScript/TypeScript > Intellisense; I noticed TypeScript version is showing as 2.2.2.0 in the Help > About window.
I wrote a String enum in one of the TS files and it compiled, so I'm guessing it's using 2.4 correctly.

The issue, I don't have type autocomplete intellisense in TS files! (working correctly in C# files)
After I finish typing something, the error checker works correctly and shows relevant errors, but no sign of autocomplete anywhere types are expected (parameters, function return, class members, local variables, etc.), not even for basic types like 'string'. Although module/class level autocomplete for words like 'function' and 'interface' is working. Any ideas, should I open a separate issue?

@billti
Copy link
Member

billti commented Aug 3, 2017

Is this with the same project? Are you only seeing intellisense issues with the same problematic project? i.e. if you create a new empty ASP.NET app and add a TypeScript file, do you get intellisense working fine there?

@TeamworkGuy2
Copy link
Author

Both the existing problematic project and a brand new ASP.NET project with a new TS file are having the auto completion issue.

@billti
Copy link
Member

billti commented Aug 3, 2017

The fact the error list is updating as you type (I assume you don't need to build to see the errors) indicates the language service is working. The fact you get intellisense in other languages and also it is appearing for keywords shows the completion list is functioning. So this is bizarre.

I wonder if it may be the command-handler not responding as you type certain keys. If in a TypeScript file you type "document." do you not see the completion list after the dot with "addEventListener" etc.? If not, with the cursor positioned after the dot, if you select from the menu "Edit / Intellisense / List members" does anything appear?

@TeamworkGuy2
Copy link
Author

If I type 'document' (I also tested with several other global objects as well as some custom objects imported via 'import ...' statements) I do see a full list of members (including fields, methods, interfaces, everything).

It's specifically type completion that's not working. After typing the colon ':' after a parameter, closing method parenthesis, field name, or local variable name I don't get anything.

@billti
Copy link
Member

billti commented Aug 3, 2017

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

@TeamworkGuy2
Copy link
Author

TeamworkGuy2 commented Aug 3, 2017

I see what you mean, but I never get autocomplete lists in type positions, if I type var x: Doc I do NOT get an autocomplete list.
Nice gif by the way :)

@billti
Copy link
Member

billti commented Aug 3, 2017

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).

@TeamworkGuy2
Copy link
Author

I checked both of those settings are checkmarked in VS2017, I tried unchecking them and that caused all autocomplete to disappear, and rechecking them and the old behavior came back. See gif below for example in VS2017.

Notice how I get member auto-complete lists for x: Document and y: string, but I don't get auto-complete while typing Doc and st.

vs2017-autocomplete-issue

@billti
Copy link
Member

billti commented Aug 3, 2017

That's bizarre. If you hit Ctrl+Space after typing say "var x: Doc" does the expected completion list appear (i.e. if you trigger it manually)?

@billti
Copy link
Member

billti commented Aug 3, 2017

p.s. You are definitely typing in a "*.ts" or a ".tsx" extension file right, and not a *.js file. Do you have any other extensions installed that may be interfering?

@TeamworkGuy2
Copy link
Author

When I pause in that gif after typing Doc and st I actually do press Ctrl+Space, as you can see, nothing happens.
Yes :), I'm editing a .ts file

@billti
Copy link
Member

billti commented Aug 3, 2017

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): #16610 (comment)

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.

@TeamworkGuy2
Copy link
Author

It worked! I enabled logging, saw the same forEach error mentioned in the thread you linked to. Tried the newer tsserver.js file and auto-complete is working! I'll try using VS2017 over the next few days and let you know if I encounter any out of memory crashes.

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?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 17, 2017

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.

@mhegazy mhegazy closed this as completed Aug 17, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Aug 17, 2017
@TeamworkGuy2
Copy link
Author

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)...

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Needs More Info The issue still hasn't been fully clarified Visual Studio Integration with Visual Studio
Projects
None yet
Development

No branches or pull requests

5 participants