Slow debugging excessive exceptions in the IDE

  • Thread starter Thread starter Neil Davidson
  • Start date Start date
N

Neil Davidson

Hi,

We're using a third party component which throws and catches
exceptions a *lot* (tens of thousands of them). When we run code that
uses this component from within the VS.NET IDE it is very slow, but
when we run it from outside (eg with CTRL-F5 rather than F5) it is
not. It seems like the debugger slows down the exception handling by a
couple of orders of magnitude.

Does anybody know of a way round this? I know it's not a great idea to
throw and catch thousands of exceptions but unfortunately this is not
something I can change.

Thanks,

Neil
 
The only thing is, attach the debugger to the process you are debugging only
right before you want to start debugging. So if you want to debug a button
click event, let your program load up and do everything else, then attach
the debugger before clicking the button.

Other then that, you may be stuck with it.
 
Hi Neil,

Based on my understanding, you meet the problem of getting the different
speed of running your application with debugger and without debugger.

Actually, this is an expected behavior. When you run your application with
debugger(F5), the IDE debugger will attach to your entire execute of your
application from the start. So the execute speed is slowing down.

You may take Marina's suggestion to debugger your application at
runtime(When necessary). To attach to a process dynamically, you may use
"Debug Processes..." menu option in "Tool" menu.
Or you can use code in your application to invoke the debugger dynamically,
using System.Diagnostics.Debugger.Launch();

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Jeffrey / Marina,

Thanks for the answers. I was hoping to be able to debug from within
the IDE without having to manually attach, but it looks like I won't
be able to.

I understand that running from within the IDE is slower. It is
normally about 10% slower, but it is 30 times slower here. The
following code takes 0.1 seconds to run outside of the IDE but 3.6
seconds inside:

for (int i=0; i<10000; i++)
{
try
{
throw new Exception();
}
catch
{
}
}

Yours,

Neil
 
Hi Neil,

Yes, I see your concern of 30 times slower when keep on throwing exceptions.

I think this is by design. The debugger will do much more extra work with
exception. I know you can not change your design of throwing so many
exceptions, but everyone will tell you that throwing so many exceptions are
not a good design!!

If you still have any concern, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Neil,

Do you still have any concern on this issue? Please feel free to feedback,
I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Jeffrey,

It'd be interesting to know why it is so slow / if there is some sort
of flag I can set to stop the IDE handling the exceptions.

- Neil
 
Hi Neil,

When you run with debugger, the VS.net debugger will run your code and then
attach to your running code process. When many exceptions are thrown in
your code, the VS.net IDE debugger will do much work on these exceptions
when initializing, because VS.net debugger MUST know these exceptions.

So this will cost a lot of time.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Neil,

Oh, I also want to inform you that, you may improve the performance a
little through disable IDE trap the unhandled exception.

In IDE, press Ctrl+ Alt+ E, in the Exceptions dialog, select "Common
Language Runtime Exceptions", then select "Continue" for "If the exception
is not handled"

This should improve the performance a little, beside this, there no other
swith to turn off.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top