2

Using Visual C# 2010 Express, when I throw an exception it takes about minute and a half for the debugger to break on a user unhandled exception. During this time the application I'm debugging and visual studio are completely unresponsive and VCSExpress.exe processor usage jumps to 12-14%. The rest of the computer (mouse, other applications, etc.) remains responsive.

Visual studio isn't completely unusable but it is definitely slowing my application down when running from the debugger. I haven't been able to find the real source of the slowdown yet. This happens right at startup and isn't a problem that gets worse over time.

I have disabled my antivirus (eset nod32 v7) and do not have any extensions installed. My CPU is an Intel Core i7 740QM @ 1.73GHz (quad-core hyperthreaded). OS is Windows 7 Professional. I've updated Visual C# 2010 Express to SP1 (Version 10.0.40219.1 SP1Rel). My hard disk shows no warning signs via S.M.A.R.T.

I have two extremely simple test scenarios written in WPF. In the first scneario I simply throw an exception when the button is clicked:

private void button1_Click(object sender, RoutedEventArgs e)
{
    throw new InvalidOperationException();
}

I manually measured the time between when I click the button and when Visual Studio displays the thrown/user unhandled exception dialogue box (and thus becomes responsive again). I tested the timing for breaking on thrown versus user-unhandled exceptions when, with and without antivirus (AV), and with and without the Visual Studio Hosting Process (VS):

Debug, Unhandled, AV on -- 1:35.3, 1:38.0
Debug, Thrown, AV on -- 0:10.4, 0:11.5, 0:11.1
Debug, Thrown, AV off -- 0:10.7
Release, Thrown, AV off -- 0:9.1, 0:10.0
Release, Unhandled, AV off -- 1:34.5
Release, Thrown, AV off, No VS Hosting -- 0:8.9, 0:9.1
Release, Unhandled, AV off, No VS Hosting -- 1:19.6, 1:20.9

When breaking on unhandled exceptions, it takes 1:30 (1 minute, 30 seconds) to recover. Antivirus makes no difference. Taking away VS Hosting saves around 15 seconds. Release mode saves about 1 second. Switching to breaking on thrown exceptions has significant savings (10 seconds to recover), though this still is not acceptable.

My second test scenario is for timing a caught exception inside and outside of Visual Studio:

private void button2_Click(object sender, RoutedEventArgs e)
{
    System.Diagnostics.Stopwatch sw = new Stopwatch();

    sw.Start();
    try
    {
        throw new InvalidOperationException();
    }
    catch { }
    sw.Stop();

    label1.Content = string.Format("{0:0.000} seconds", sw.ElapsedMilliseconds / 1000.0);
}

For this scenario, I set VS to break only on unhandled exceptions so I could get timing data for simple caught exceptions. I ran this in VS and outside of VS as the stand-alone EXE:

Release, Unhandled, AV off, No VS Hosting -- 0:1.965, 0:1.812, 0:1.985
Debug, Unhandled, AV off, No VS Hosting -- 0:2.333, 0:2.136, 0:2.305
Release EXE, AV off -- 0:0.002, 0:0.000, 0:0.000
Debug EXE, AV off -- 0:0.002, 0:0.000, 0:0.000

Outside of VS there is no slowdown. Inside of VS this takes about 2 seconds, which still seems pretty excessive for a quad core hyperthreaded CPU and a tiny try/catch block.

I'm pursuing some of the leads in the linked questions (system environment settings, etc.) and monitoring the file system/disk activity to see if I can get any leads. Any additional help is much appreciated!

btw, I'd prefer not to re-install Visual Studio or my OS

Thanks!

Update I've installed VS 2012 Express, and the numbers are:

Test 1:
Debug, Unhandled, AV off -- 0:01.6
Debug, Thrown, AV off -- 0:01.1

Test 2:
Debug, VS Hosting -- 0:1.202
Debug, No VS Hosting -- 0:1.191
Release, VS Hosting -- 0:1.220

The numbers in VS2012 are much better. Clearly one solution to my problem is upgrading to VS2012, which is what I'm planning on doing. But I'd still like a resolution to this problem if anyone has any ideas.

Community
  • 1
  • 1
cod3monk3y
  • 9,508
  • 6
  • 39
  • 54
  • Have you run your test on an optimized release build completely out of the development environment? The first step is to confirm that it only happens in the IDE. Also what is VS resource usage when this is happening? Also does the callstack window refresh before or after the symptoms resolve? – drankin2112 Dec 16 '13 at 23:40
  • Also, Have you tried manually doing a garbage collection? When debugging with focus on IDE, press CTL+SHIFT+ALT + (F12 twice) and see if that speeds things up. Does the IDE ever freeze briefly while you're typing? Have you been having any trouble with windows automatic updates? I'm not saying this is the problem but my WU got corrupt somehow recently and just kept trying to download the same updates over and over again, so I turned it off. When I did finally get around to fixing it, my IDE magically stopped freezing. – drankin2112 Dec 16 '13 at 23:54
  • @drankin2112 Thanks for the reply. The `Release EXE` and `Debug EXE` lines above are the debug and optimized release versions that show the performance "outside of VS" showing that the performance is Visual Studio. Additionally there is no problem with Visual Studio 2012, as I mentioned in my update. – cod3monk3y Dec 18 '13 at 20:00
  • @drankin2112 -- I have not been having problems with Windows Update. I have not tried forcing a garbage collection. My test application is as simple as you see in the code above: a WPF app with a button click handler. Right now I've uninstalled VS 2010 C# Express, so I can't run these tests. But when I get it re-installed I'll give it a go and get back to you. – cod3monk3y Dec 18 '13 at 20:02
  • No problem. I'm just trying to offer simple trouble shooting advise. I hate when packages like Visual Studio seem to not work propertly, only for me! When you get VS2010 back up and running, another thing to investigate is whether the same thing happens in a Windows Forms app. Then you would know if its just WPF. I wish you the best of luck! – drankin2112 Dec 18 '13 at 20:12
  • Definitely appreciate the advice. I hadn't thought of checking WU or forcing GC, nor checking WinForms. I'll also try out a console app once I get it re-installed. – cod3monk3y Dec 18 '13 at 20:29

0 Answers0