13

When stepping through my C# code line by line via F10, it takes the debugger over one second to get to the next line.

I've tried deleting all watches and breakpoints, but that did not make any difference.

Is this normal? It's been like this for quite a long time now, so I can't even remember if this was ever better. My development computer is a Quad-core machine with no background task activity and plenty of RAM left.

If it's not normal, what else could I try? It's still ok to work with, but a less sluggish user interface would be great...

9 Answers 9

14

What's likely happening is you have a variable in the call stack frame which has an expensive .ToString method. In 2008, the data for the call stack window is rebuilt on every step regardless of whether or not the window is actually visible. Part of building this window will call .ToString on the values which appear in the parameter list if they have an overridden .ToString. Try disabling implicit .ToString calls and see if that fixes the problem.

  • Tools -> Options -> Debugger
  • Uncheck the "Enable Implicit .ToString calls"
Sign up to request clarification or add additional context in comments.

3 Comments

In Visual Studio 2010 the call stack window seems to only be rebuilt when it is actually visible. An alternative to disabling implicit ToString calls is to right-click on the call stack window and untick 'Display Parameter Values'.
@Phil, this was a performance change we made just before Beta2.
Thank you!! My problem was actually caused by a DebuggerDisplayAttribute on one of my classes being overly intensive. I moved the logic into the ToString() method and it was much faster. Nice to know it was the property value calculation that was slowing things WAY down. Thanks!!
5

I have found that if you have the option to debug unmanaged code turned on, the debugger can take a while to step between lines even if you are only debugging managed code. Try turning that option off (Project > Properties > Debug > Enable Debuggers > Enable unmanaged code debugging).

5 Comments

+1 last time I experienced slow stepping in visual studio this was the cause
Sounds great, but where exactly can I find this option? I haven't seen it anywhere in my roject settings.
I believe it is under the debugging group, but I'm at home and can't check. Also, this option may not be available in Visual C# Express.
I'm on Visual Studio Team System, but there is no Debugging group in ASP.NET Web Project settings. Perhaps you mean Tools -> Options -> Debugging -> Just-In-Time -> Native? I've just tried disabling that though and id did not seem to have any effect.
This option is available for Windows Forms and Class library projects and is found under Project > Properties > Debug > Enable Debuggers > Enable unmanaged code debugging. This does not appear to be available for web projects, at least not under project properties.
4

I tried all of the above. Unchecking 'Show Threads In Source' button fixed it.

Comments

3

In my case, disabling "break all processes when one process breaks" (Tools/Options/Debugger) reduced the time to "step over" from 2-3 seconds to a fraction of a second.

I have no idea why this option had such a big effect on doing a single step over. BTW, I suppose that disabling this option might cause trouble if you are using threads that are not independent from each other.

2 Comments

I had the same issue. Thanks. I'm gonna investigate this.
This fixed my slow debugging issue in VS2010.
1

I once experienced slow debugging as I had set up VS to look for pdb files on a network share that didn't exist any more.

Check here : Tools - options - Debugging - Symbols - Symbol file (.pdb) Locations

Comments

1

I've heard of this kind of problem if the "Auto" window is open. Try closing that and see if your performance improves.

If you haven't already, you should probably also install the "Visual Studio 2008 SP1 debugging and breakpoint" patch. Note that this patch goes on top of SP1. The docs for the patch don't specifically address the slowness that you're seeing, but it's a pretty large patch, and you might get lucky.

Comments

1

Turn off the Enable address-level debugging option in Tools > Options > Debugging > General.
It made a huge difference for me.

Comments

0

Do you have a lot of Watch expressions set up ? They will be evaluated after between each step, and if they take time to run, you will notice it as a delay when stepping.

1 Comment

No, I have already deleted all watches to make sure this is not the problem.
0

I was experiencing a 10 second delay after stopping C# debugging before being able to start C# debugging again. VS2008 would hang during this time with nothing clickable. There is now a 0 second delay after I disabled the Visual Studio hosting process in Project Properties -> Debug.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.