You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Visual Studio 2017 hangs, crashes when opening large F# solution #2793
We have a large (~90 projects) solution, mostly F#. In VS2015 it takes maybe 20-30 seconds to open and the memory usage is around 400MB. In VS2017, the IDE hangs after loading all the projects, memory usage quickly climbs in the 3GB range, and it can stay like that for several minutes before eventually crashing.
This seems related to F# as larger C# solutions don't present this problem.
This is closed-source so of course I cannot share the code, but I would be glad to provide any non-sensitive data to help diagnose this issue. I tried simply creating a new solution and adding our projects to it one by one. Around 60 projects the IDE became extremely slow and usually cannot open the solution anymore. If it manages to get past this loading phase, memory usage goes back to something normal. Then sometimes it becomes usable, sometimes it crashes anyway.
I just tried this again with VS Community 2017 (15.0.0+26228.12) and Visual F# Tools 15.4.1.17040401.
Here's a vmmap screenshot while it's hovering around 3GB:
Yes I just open Visual Studio 2017 and open the solution.
Not sure about sharing a dump, it's going to have file names and whatnot... but here are some screenshots in dotMemory when devenv.exe was around 1GB and climbing:
Maybe 2 million FSharpChecker objects is a lot? Or maybe going by the vmmap info it might not be managed objects at all?
So this is all happening before any files are open in the editor. VS is hung on the Start Page, the Solution Explorer is empty. If it manages to load it (I have a smaller one with 61 projects that just barely loads, sometimes), right now one .fs file opens in the editor. Then it's kinda laggy and sometimes it manages to fall back on its feet and become usable, sometimes it crashes anyway. The diff from my last post was on this solution.
The full 90 projects solution never makes it to that stage though. You get the dialog saying it's loading the projects, that dialog completes and disappears, then it just stays there and eventually crashes.
Using your VSIX, I get "The 'FSharpProjectPackage' package did not load correctly in VS". In ActivityLog.xml this seems relevant:
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\***\AppData\Local\Microsoft\VisualStudio\15.0_4ee222e8\Extensions\thoyrmux.2tv\FSharp.ProjectSystem.FSharp.dll' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
File name: 'file:///C:\Users\***\AppData\Local\Microsoft\VisualStudio\15.0_4ee222e8\Extensions\thoyrmux.2tv\FSharp.ProjectSystem.FSharp.dll' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)
Well, on the smaller (61 projects) solution, with your VSIX it seems to more reliably open it and let me use it, after a very long loading time and going well into 2GB of RAM. But the full one still crashes as before.
Good news! I can actually repro with @saul 's generated solution, on my work environment. I have no idea why in this environment the memory balloons out of control, whereas at home it doesn't. But maybe at home I'm not running the latest nightly. I'll retest when I get time.
So it does load our solution, pretty fast as well. However, after that, trying to open files from the solution explorer I am often greeted with
and there is no syntax highlighting at all, even on small solutions. Just walls of white text.
I believe I know how to fix this problem. We will have to change the shape of CompileOptions to no longer recursively specify the dependent projects but rather provide a list of projects options indexed by DLL name. I will work on a PR for this tomorrow
Activity
vasily-kirichenko commentedon Apr 4, 2017
Would you mind to take a gotMemory snapshot and share it?
vasily-kirichenko commentedon Apr 4, 2017
Do I understand correctly that no files are open?
asik commentedon Apr 4, 2017
Yes I just open Visual Studio 2017 and open the solution.
Not sure about sharing a dump, it's going to have file names and whatnot... but here are some screenshots in dotMemory when devenv.exe was around 1GB and climbing:
Maybe 2 million FSharpChecker objects is a lot? Or maybe going by the vmmap info it might not be managed objects at all?vasily-kirichenko commentedon Apr 4, 2017
Wow o_O. There should be strictly one
FSharpCheckervasily-kirichenko commentedon Apr 4, 2017
Can you show retaining paths for FSharpChecker?
asik commentedon Apr 4, 2017
Oh wait, the number on the right is the number of objects under it. So there are only 2 FsharpChecker objects here (the number on the left).
asik commentedon Apr 4, 2017
As vmmap suggests it looks like the growth in .NET objects is not the problem, it's mainly unmanaged memory:
FWIW though here are the deltas for .NET objects, sorted by Objects delta:
vasily-kirichenko commentedon Apr 4, 2017
From how many projects do you have files opened? Can you open a single file from any project (and restart)?
asik commentedon Apr 4, 2017
So this is all happening before any files are open in the editor. VS is hung on the Start Page, the Solution Explorer is empty. If it manages to load it (I have a smaller one with 61 projects that just barely loads, sometimes), right now one .fs file opens in the editor. Then it's kinda laggy and sometimes it manages to fall back on its feet and become usable, sometimes it crashes anyway. The diff from my last post was on this solution.
The full 90 projects solution never makes it to that stage though. You get the dialog saying it's loading the projects, that dialog completes and disappears, then it just stays there and eventually crashes.
vasily-kirichenko commentedon Apr 4, 2017
Do you mind try https://drive.google.com/open?id=0B8HLQUKik9VtNFF1UEZNaElhZTg? I reduce project cache size from 200 to 5 in this build. First, open the dev command prompt and run
Common7\IDE\VSIXInstaller.exe /uninstall:VisualFSharpThen run my vsix.
asik commentedon Apr 4, 2017
Using your VSIX, I get "The 'FSharpProjectPackage' package did not load correctly in VS". In ActivityLog.xml this seems relevant:
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\***\AppData\Local\Microsoft\VisualStudio\15.0_4ee222e8\Extensions\thoyrmux.2tv\FSharp.ProjectSystem.FSharp.dll' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
File name: 'file:///C:\Users\***\AppData\Local\Microsoft\VisualStudio\15.0_4ee222e8\Extensions\thoyrmux.2tv\FSharp.ProjectSystem.FSharp.dll' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)vasily-kirichenko commentedon Apr 4, 2017
Ah, you have to disable strong validation checking.
Another thought: can it be the case that your solution has circular project references?
vasily-kirichenko commentedon Apr 4, 2017
sn -Vr *,*asik commentedon Apr 4, 2017
The solution doesn't have circular references. I thought this was impossible but I was curious so I wrote a program to verify it; it really doesn't.
I'm seeing the same behavior using your VSIX.
asik commentedon Apr 4, 2017
Well, on the smaller (61 projects) solution, with your VSIX it seems to more reliably open it and let me use it, after a very long loading time and going well into 2GB of RAM. But the full one still crashes as before.
18 remaining items
asik commentedon Apr 5, 2017
Good news! I can actually repro with @saul 's generated solution, on my work environment. I have no idea why in this environment the memory balloons out of control, whereas at home it doesn't. But maybe at home I'm not running the latest nightly. I'll retest when I get time.
So anyway, dotTrace snapshot from VS slowly dying:
https://www.dropbox.com/s/13swowphpptk8a4/VS2017%20timeline%20snapshot.7z?dl=0
vasily-kirichenko commentedon Apr 6, 2017
@asik could you try #2801, grab vsix here https://drive.google.com/open?id=0B8HLQUKik9VtSlBtVTdfUHhYMjQ?
asik commentedon Apr 6, 2017
So it does load our solution, pretty fast as well. However, after that, trying to open files from the solution explorer I am often greeted with

and there is no syntax highlighting at all, even on small solutions. Just walls of white text.
saul commentedon Apr 7, 2017
@asik that is left over from Vasily's investigation. To fix it, create that file on your disk.
vasily-kirichenko commentedon Apr 7, 2017
That VSIX is not usable anyway, it's just POC where the problem is. I'm not gonna provide a fix.
dsyme commentedon May 6, 2017
@saul @vasily-kirichenko @cloudRoutine I added the stress test projects generated by @saul directly to the repo in #2997. They are in tests\projects\stress
Checking in the files directly is a bit brutal but we need to have at least a few project stress tests we can share, focus on and automate
dsyme commentedon May 6, 2017
Perf info for opening
tests\projects\stress\medium\dense\Dense.sln:Inclusive:

Exclusive:

dsyme commentedon May 7, 2017
I believe I know how to fix this problem. We will have to change the shape of CompileOptions to no longer recursively specify the dependent projects but rather provide a list of projects options indexed by DLL name. I will work on a PR for this tomorrow
dsyme commentedon May 9, 2017
@saul I've merged #3002 and will close this bug to match, but please submit your run-on-the-background improvements too
Fix some assertions in debug mode (#3010)
Fix some assertions in debug mode (dotnet#3010)