Tuesday 28 February 2012

Visual Studio hanging / running slowly

Suffered from this today, and discovered that deleting the large > 350MB .suo file for the solution fixed the problem.

Turns out that if you use a lot of bookmarks, and break points this file can grow exponentially, as the file never appears to decrease in size, even after deleting old breakpoints and book marks, only keeps growing!

Baretail, showed that devenv.exe was just constantly writing out that same lines to the .suo file over and over again.

Have renamed the .suo file now, and VS appears to be working a little better. Not sure what project / solutions settings I will be missing though.

Also appears from Proc mon that it keeps trying to find the .suo file for the solution

clip_image002

However, VS is behaving fine for now, so going to keep on working like this.

More info about it here

http://blog.richardszalay.com/2010/01/25/massive-suo-file-causes-visual-studio-to-hang-when-doing-pretty-much-anything/

There is however a work around that someone has listed on the community content section of this msdn post, on how to create a macro that will automatically delete the .suo file after the solution closes.

http://msdn.microsoft.com/en-us/library/bb165909.aspx

How to prevent the .suo file from being persisted.

It is possible to do this with macros that respond to the IDE's SolutionEvents.BeforeClosing and SolutionEvents.AfterClosing events.

  1. In the BeforeClosing event, store the value of the DTE.Solution.FullName property in the EnvironmentEvents module.
  2. In the AfterClosing event, get the .suo file by using System.IO.Path.ChangeExtension on the stored file name.
  3. Delete the file with File.Delete.

Bam. No more persisted .suo files for any VS 2010 solutions. An absolute MUST if your 150-project solution takes 20+ minutes for C# IntelliSense to load.

image

Stick this in the Public Module EnvironmentEvents body...

Dim solutionName As String

Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing

    solutionName = DTE.Solution.FullName


End Sub

Private Sub SolutionEvents_AfterClosing() Handles SolutionEvents.AfterClosing

    Dim suoFilePath As String

    suoFilePath = System.IO.Path.ChangeExtension(solutionName, "suo")

    If Not System.IO.File.Exists(suoFilePath) Then
        Return
    End If


    Dim fileInfo As System.IO.FileInfo = New IO.FileInfo(suoFilePath)

    If fileInfo.Length > 3000000 Then '3MB file size would be quite large.

        Dim response As MsgBoxResult

        response = MsgBox("The solution user options file '" & suoFilePath + "' is " _
                          & fileInfo.Length.ToString() & _
                          " bytes large. Do you wish to delete this file in order to increase the performance of the solution?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, _
                           "Delete solution user options file?")

        If response = MsgBoxResult.Yes Then

            System.IO.File.Delete(suoFilePath)

        End If
    End If

End Sub

 

Further to this, I've just been informed of this trick as well for speeding things up...

Another solution I’ve used in the past is to close Visual Studio, then clear the cache.

You would go to C:\Users\[user]\AppData\Local\Microsoft\Team Foundation\[version#]\Cache, and delete all contents. In older Windows versions, you would navigate to C:\Documents and Settings\[USER]\Local Settings\Application Data\Microsoft\Team Foundation\[Version#]\Cache, and delete all contents.

The first time you start VS after that will be a little slow, as it has to recreate the VersionControl settings, but after that you should see a big improvement.

No comments:

Post a Comment

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...