Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Monday, June 20, 2016

Visual Studio Debugging/Loading Very Slow

Visual Studio Debugging/Loading Very Slow


I'm at wits end. Visual Studio is typically painfully slow to debug or just plain load ("start without debugging") my MVC sites. Not always: at first, the projects will load nice and fast, but once they load slow, they'll always load slow after that. I could be waiting 1-2 minutes or more.

My setup:

I'm using Visual Studio 2012 express, currently, but I've had the same problem in 2010 as well. My solution is stored on a network drive; specifically, it's My Documents redirected to a network drive, if it matters. [It shouldn't. There are times where my site loads very fast under this setup.]

I load in IE 9 usually, but the same problem happens in FireFox.

This can happen in any MVC project I work on, and seems to revolve around having DisplayTemplates, which all my MVC projects do. And it's all C# & Razor, if that mattered.

Symptoms:

The system will load my symbols hundreds of times. Basically, the following, but there are at least 300 such rows, each with ever-so-slightly different DLLs for the same CSHTMLs:

'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_contact.cshtml.22013bb9.xighmhow.dll', Symbols loaded.  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_contact.cshtml.22013bb9.cv5hktkf.dll', Symbols loaded.  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.1o77hs8i.dll', Symbols loaded.  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.jja-77mw.dll', Symbols loaded.  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_location.cshtml.22013bb9.l_e9ev_s.dll', Symbols loaded.  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_location.cshtml.22013bb9.b4n59gom.dll', Symbols loaded.  

In the above, I've got 3 DisplayTemplates: "Contact", "Location", and "StatusCode". It appears that IIS is loading symbols twice for each time the displaytemplate gets called. Thus, if I'm displaying a table of 100 entries that calls all 3 of these displaytemplates, it's 600 separate symbols loaded.

This isn't a fast operation either. Looking in the log files that IIS generates, it takes about 200ms for each symbol to load. Thus, super-long delays.

What I've Tried:

  • Debug or Release version, doesn't matter.
  • Putting my project on a full IIS implementation on a web server runs it super fast with no problems.
  • Cassini, iisexpress 7.5, iisexpress 8.0 all have the problem.
  • Delete All Breakpoints does nothing.
  • Clean Solution, or deleting the .suo also do nothing.
  • If I repair IISExpress, or delete the My Docs\IISExpress folder, or repair/reinstall Visual Studio -> the issue MAY go away, but only for a while, before it comes right back.

Any advice at all is appreciated.

---- Edit #1 -----

To answer more questions, yes my machine definitely has the horsepower. The infuriating thing is that the same project, with NOTHING altered, can load very very quickly sometimes, typically after I repair IISExpress & delete the My Docs\IISExpress folder. Eventually "something" happens and it's down to 2 minutes to load again. What I'm working on is not a complicated project. No external libraries or dependencies, and my VS.NET has no addons what-so-ever.

Of note, this machine has Symantec Endpoint Protection, which has a history of causing havoc. But disabling it outright (its good to be an admin) did not fix the problem.

I have a theory at this point. I'm thinking this is all because I'm working off a redirected folder off a network share. While the debugger was going through it's hundreds of "loaded symbols" lines, I paused to see what it was doing. It was in my code, loading the DisplayTemplate I had. Stepping into the template output this:

Step into: Stepping over non-user code 'System.Threading.WaitHandle.InternalWaitOne'  Step into: Stepping over non-user code 'System.Threading.WaitHandle.WaitOne'  Step into: Stepping over non-user code 'System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated'  Step into: Stepping over non-user code 'System.CodeDom.Compiler.Executor.ExecWaitWithCapture'  Step into: Stepping over non-user code 'Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch'  Step into: Stepping over non-user code 'Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch'  Step into: Stepping over non-user code 'System.Web.Compilation.AssemblyBuilder.Compile'  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.bciuyg14.dll', Symbols loaded.  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.CompileWebFile'  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVPathBuildResultInternal'  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert'  Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory'  Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists'  Step into: Stepping over non-user code 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName'  Step into: Stepping over non-user code 'System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView'  Step into: Stepping over non-user code 'System.Web.Mvc.ViewEngineCollection.Find'  Step into: Stepping over non-user code 'System.Web.Mvc.ViewEngineCollection.FindPartialView'  Step into: Stepping over non-user code 'System.Web.Mvc.Html.TemplateHelpers.ActionCacheViewItem.Execute'  'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.kwj3uqan.dll', Symbols loaded.  Step into: Stepping over non-user code 'System.RuntimeType.CreateInstanceSlow'  Step into: Stepping over non-user code 'System.Web.Mvc.DependencyResolver.DefaultDependencyResolver.GetService'  Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerViewEngine.DefaultViewPageActivator.Create'  Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerCompiledView.Render'  

It looks like VS is recompiling my displaytemplate every time it's called, which is again, hundreds of times. My theory is that VS compiles the file, saves it to the network share, the network share then somehow stamps a new time on it, and VS then thinks the file has changed and thus VS recompiles it yet again. Only a theory though; I really have no clue.

For one, apparently I have offline files on (this is a desktop computer in an office; I couldn't care less). I'm going to disable, reboot and retry tomorrow.

Plus, moving my project, as is, to the local C: fixes it. It loads very quickly. But this is not ideal in a work environment. I lose Previous Versions, my code isn't backed up at all unless I manually copy it, and it's no longer shared with anyone.

I can make do copying it back and forth from C to the network share, if it comes to it. It's much more annoying to wait 2 minutes for every page load.

Answer by Ber'Zophus for Visual Studio Debugging/Loading Very Slow


I think I may finally at least know the cause, though not the reason why. When the problem started occurring again, I noticed a ton of "conhost.exe" processes orphaned. I would close Visual Studio and they would remain open. Ending task on each of them has finally, reliably solved the problem. [hopefully]

(Just note, conhost.exe isn't a Visual Studio process though Visual Studio uses it. Thus, other users out there may have other applications out there that run conhost.exe. I know my machine doesn't which is why I can safely end task all of them but YMMV.)

As to why this happens? It seems to occur when I open more than one project at once, which I tend to do often, even though I only build and debug one of them at any time.


Edit #1 - This isn't a "silver bullet" unfortunately. It doesn't always work for me. Typically, when things get slow, I just close all of my Visual Studio sessions, then go into the task manager and end any instance of it, conhost.exe, iisexpress.exe Microsoft.VisualStudio.Web.Host.exe and MSBuild.exe I can find.

Typically, after that, when I restart my project it'll then load quickly. But not always.

Really I think the best course of action is probably to not build & debug code off a redirected folder/network share.


Edit #2 - Two years later, and this is still an issue for me in Visual Studio Community 2013, but I did seem to at least find the culprit task: Explorer.exe. Yeah, who knew. The moment I end that task, bam, page loads in a single second.

If I have a Windows Explorer file browser open to my redirected network drive (which is often since that's where my code is), this problem seems to occur. Closing the window isn't enough, I have to kill the whole Explorer.exe task. I could only guess what it's doing...going nuts with file handles?

I can usually use the task manager to start up a new explorer.exe task (I can only take so much alt-tabbing), and Visual Studio will continue to load nice and quick. But if I so much as open Windows Explorer again, it almost always goes back to super-slow-mo.

So, if you've got a redirected network share, give it a shot. It sure beats working locally.

Answer by Paulius Zaliaduonis for Visual Studio Debugging/Loading Very Slow


I had problems with slow Visual Studio debugging when "Native Code" debugger was enabled. Try disabling it.

On "Visual Studio 2012" go to:

  1. Project Properties ->
  2. Web ->
  3. Debuggers (bottom of page). ->
  4. Disable all except ASP.NET

Hope it helps.

Similar questions: 1, 2

Answer by Trap for Visual Studio Debugging/Loading Very Slow


In my case I noticed that disabling my internet connection would make it run as fast as with ctrl-f5, so I went to debug->options->symbols and just unchecked all .pdb locations.

Seems like VS was trying to connect to these servers every time a debug session was launched.

Note that disabling Debug->Options->Debugging->General "Enable source support" or "Require source files to exactly match the original version" wouldn't make any difference.

Answer by Zeb Kimmel for Visual Studio Debugging/Loading Very Slow


Here is how I solved the "slow symbol loading" problem in Visual Studio 2012:

  • Go to Tools -> Options -> Debugging -> General

  • CHECK the checkmark next to "Enable Just My Code".

  • Go to Tools -> Options -> Debugging -> Symbols

  • Click on the "..." button and create/select a new folder somewhere on your local computer to store cached symbols. I named mine "Symbol caching" and put it in Documents -> Visual Studio 2012.

  • Click on "Load all symbols" and wait for the symbols to be downloaded from Microsoft's servers, which may take a while. Note that Load all symbols button is only available while debugging.

  • UNCHECK the checkmark next to "Microsoft Symbol Servers" to prevent Visual Studio from remotely querying the Microsoft servers.

  • Click "OK".

From now on, symbol loading should be much faster.

Note that if you make any changes/downloads to Microsoft assemblies, you may need to go back into the Symbols dialog box and "Load all symbols" again.

Answer by Andrew Davis for Visual Studio Debugging/Loading Very Slow


I don't know if you're still having this issue, but I debug sites in Visual Studio by attaching the debugger to the process itself rather than letting VS do it for me and I have found it to greatly improve times. I use an extension for VS called AttachTo and I have a small article on how I use it here.

I hope this helps.

Answer by user2144480 for Visual Studio Debugging/Loading Very Slow


none of this worked for my but I found a break point on a symbol that was deleted. Seems 2010 was hanging on it. To see if this is your issue do debug->windows->breakpoints If any are in there just delete them.

Saunders, mentioned he check for that but it was not mentioned in the solutions for this problem. Maybe common knowledge for some, but not all of us.

Answer by zmercier for Visual Studio Debugging/Loading Very Slow


If someone notices this behavior coming out of left field, check to make sure you don't have any breakpoints set in web.config. I must have set one with a stray mouse click, and it really slowed down all debug operations.

Answer by arkhivania for Visual Studio Debugging/Loading Very Slow


I had execution perfomance troubles with debugging too and i tried very many options of debugger. In my case huge perfomance achieved when i change this options:

Tools - Options - Debugging - Output Window - (General output settings - All debug output) - OFF

Answer by moke for Visual Studio Debugging/Loading Very Slow


Turning off intelliTrace fixed this for me.

In Visual Studio, Tools -> Options -> IntelliTrace

Then, uncheck the checkbox for "Enable IntelliTrace".

Disable IntelliTrace in Visual Studio 2012

Answer by BuddhiP for Visual Studio Debugging/Loading Very Slow


Similar problem wasted better half of my day!

Since solution for my problem was different from whats said here, I'm going to post it so it might help someone else.

Mine was a breakpoint. I had a "Break at function" breakpoint (i.e instead of pressing F9 on a code line, we create them using the breakpoints window) which is supposed to stop in a library function outside my project.

And I had "Use Intellisense to verify the function name" CHECKED. (Info here.)

This slowed down vs like hell (project start-up from 2 seconds to 5 minutes).

Removing the break point solved it for good.

Answer by UserBlueOne for Visual Studio Debugging/Loading Very Slow


For me it was IE 9.08.8112.16241. As soon as I used Firefox or Chrome there was no sluggish debugging with F10 or F11. I do not know what the problem with IE is but I officially despise using it for testing now.

Update: I have turned off all IE program add-ons and it is back to full speed. Turning them on one at a time revealed that LastPass (in my case) was the culprit. I guess I do not get to blame MS after all.

Answer by Shaun Kennedy for Visual Studio Debugging/Loading Very Slow


I deleted the "Temporary ASP.NET Files" folder and my localhost page load improved dramatically. Here is the path... %temp%\Temporary ASP.NET Files\

Answer by Tahir Hassan for Visual Studio Debugging/Loading Very Slow


The above are all good solutions and I tried all of them, but got the solution here, which is to

Debug -> Delete All Breakpoints  

Answer by UserBlueOne for Visual Studio Debugging/Loading Very Slow


There is also complications in partial views where there is an error on the page that is not recognized immediately. Like Model.SomeValue instead of Model.ThisValue. It might not underline and cause problems in debugging. This can be a real pain to catch.

Answer by Dimitri C. for Visual Studio Debugging/Loading Very Slow


Emptying the symbol cache worked for me.

See: menu bar / Tools / Options / Debugging / Symbols / Empty Symbol Cache

Answer by Larry for Visual Studio Debugging/Loading Very Slow


One time, after a power outage, I had to face the same slowness problem each time a breakpoint was hit or a Exception was thrown.

I had the vague remembering that the "suo" file (in the same directory as the "sln" solution file) can be corrupted and make everything slow down.

enter image description here

I deleted my "suo" files and everything was ok. The .suo files deletion is harmless and only implies to recreate my windows layout plus the starting project and a few other non critical customizations.

Answer by shamp00 for Visual Studio Debugging/Loading Very Slow


In my case, it was the .NET Reflector Visual Studio Extension (version 8.3.0.93) with VS 2012. Debugging was taking 10 seconds for each Step Over (F10).

In Visual Studio, go to Tools/Extensions and Updates... and disable the .NET Reflector Visual Studio Extension. Don't forget to restart Visual Studio.

Answer by David for Visual Studio Debugging/Loading Very Slow


One thing that worked for me after doing all the above was:
In the Threads window (Debug->Windows->Threads), set Group by to None. This can only be done while debugging.

This was having an impact even after closing that window.

Answer by aricons for Visual Studio Debugging/Loading Very Slow


I experienced the same problem and tried most of the resolutions above. Simply deleting cache and temp files end up working for me.

Try removing the contents of these two folders:

C:\Users{UserName}\AppData\Local\Microsoft\WebsiteCache

and

C:\Users{UserName}\AppData\Local\Temp (in particular the iisexpress and Temporary ASP.NET Files folders).

Answer by rkawano for Visual Studio Debugging/Loading Very Slow


Do you have enabled FusionLog?

My VisualStudio was very slow to start, open solution and load symbols when start debugging. It was slow only on my machine, but not on other machines.

FusionLog writes tons of log stuff to disk. Just disabling it on RegEdit solved everything, on my case.

This is the FusionLog key on registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion  

Check ForceLog value (1 enabled, 0 disabled).

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.