Skip to content

Visual Studio 2017 hangs, crashes when opening large F# solution #2793

Closed

Description

@asik

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:

image

Activity

  1. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    Would you mind to take a gotMemory snapshot and share it?

  2. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    Do I understand correctly that no files are open?

  3. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

    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:

    image
    image
    image

    Maybe 2 million FSharpChecker objects is a lot? Or maybe going by the vmmap info it might not be managed objects at all?

  4. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    Wow o_O. There should be strictly one FSharpChecker

  5. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    Can you show retaining paths for FSharpChecker?

  6. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

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

  7. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

    As vmmap suggests it looks like the growth in .NET objects is not the problem, it's mainly unmanaged memory:

    image

    FWIW though here are the deltas for .NET objects, sorted by Objects delta:

    image

  8. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    From how many projects do you have files opened? Can you open a single file from any project (and restart)?

  9. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

    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.

  10. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    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:VisualFSharp

    Then run my vsix.

  11. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

    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)

  12. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    Ah, you have to disable strong validation checking.

    Another thought: can it be the case that your solution has circular project references?

  13. vasily-kirichenko commented on Apr 4, 2017

    @vasily-kirichenko
    Contributor

    sn -Vr *,*

  14. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

    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.

  15. asik commented on Apr 4, 2017

    @asik
    ContributorAuthor

    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.

  16. 18 remaining items

  17. asik commented on Apr 5, 2017

    @asik
    ContributorAuthor

    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

  18. vasily-kirichenko commented on Apr 6, 2017

    @vasily-kirichenko
    Contributor
  19. asik commented on Apr 6, 2017

    @asik
    ContributorAuthor

    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
    image
    and there is no syntax highlighting at all, even on small solutions. Just walls of white text.

  20. saul commented on Apr 7, 2017

    @saul
    Contributor

    @asik that is left over from Vasily's investigation. To fix it, create that file on your disk.

  21. vasily-kirichenko commented on Apr 7, 2017

    @vasily-kirichenko
    Contributor

    That VSIX is not usable anyway, it's just POC where the problem is. I'm not gonna provide a fix.

  22. dsyme commented on May 6, 2017

    @dsyme
    Contributor

    @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

  23. dsyme commented on May 6, 2017

    @dsyme
    Contributor

    Perf info for opening tests\projects\stress\medium\dense\Dense.sln:

    Inclusive:
    image

    Exclusive:
    image

  24. dsyme commented on May 7, 2017

    @dsyme
    Contributor

    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

  25. dsyme commented on May 9, 2017

    @dsyme
    Contributor

    @saul I've merged #3002 and will close this bug to match, but please submit your run-on-the-background improvements too

  26. added a commit that references this issue on May 9, 2017
  27. modified the milestones: , 15.2 on Jun 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Impact-HighReadyRegression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions