visual-studio 调试有时很慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/805397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:25:16  来源:igfitidea点击:

Debugging sometimes very slow

visual-studiodebugging

提问by kaze

I'm using VS2008, in a normal mid-size solution.

我在正常的中型解决方案中使用 VS2008。

Sometimes, debug stepping becomes very slow. A padlock gets rendered on the every file tab for every "step" (F10/F11), and it can take up to two seconds for every step. That makes debugging very annoying and slow. Has anyone seen this problem?

有时,调试步进变得非常缓慢。每个“步骤”(F10/F11)的每个文件选项卡上都会呈现一个挂锁,每一步最多可能需要两秒钟。这使得调试非常烦人和缓慢。有没有人见过这个问题?

采纳答案by Brian

Yes, Visual Studio is extremely slow at debugging at times. There are a number of additional steps (in addition to turning off the Enable property evaluation" setting) you can take to speed up the process. Essentially, it requires massive amounts of RAM, so performing a few things to free that up will help.

是的,Visual Studio 有时在调试时非常慢。您可以采取一些额外的步骤(除了关闭“启用属性评估”设置)来加速该过程。本质上,它需要大量的 RAM,因此执行一些操作来释放它会有所帮助。

  1. Go into the preferences of Visual Studio. Look for all the options relating to animating menus and so forth. These have a tendency to be intensive at times, while not specific to debugging as you usually aren't opening up menus, it does seem to help.

  2. On the computer itself, if you right-click on my computer. Go to the advanced tab and under performance. If you adjust your computer for best performance it'll speed things up. It gets rid of any nice styles on your computer, but it'll free up some of the memory you are wanting.

  3. Close any unnecessary programs. The more memory you can give Visual Studio the better it is going to behave.

  1. 进入 Visual Studio 的首选项。查找与动画菜单等相关的所有选项。这些有时会很密集,虽然不是特定于调试的,因为您通常不会打开菜单,但它似乎确实有帮助。

  2. 在计算机本身上,如果您右键单击我的计算机。转到高级选项卡和性能下。如果您调整计算机以获得最佳性能,它会加快速度。它摆脱了您计算机上任何漂亮的样式,但它会释放您想要的一些内存。

  3. 关闭所有不必要的程序。为 Visual Studio 提供的内存越多,它的行为就越好。

回答by

I've noticed in VS 2008 that if you have the 'Show Threads in Source' button selected in the debug toolbar that stepping can be at least 10 times slower.

我在 VS 2008 中注意到,如果您在调试工具栏中选择了“在源中显示线程”按钮,则步进速度至少会慢 10 倍。

I've also noticed that if your application takes a long time to start in debug mode that this can be resolved if you simply 'Delete All Breakpoints' under the Debug menu. This solved an annoying problem for me even though I only had a handful of breakpoints set at the time.

我还注意到,如果您的应用程序需要很长时间才能在调试模式下启动,如果您只需在“调试”菜单下“删除所有断点”,就可以解决这个问题。这为我解决了一个烦人的问题,即使我当时只设置了少数断点。

Silas

塞拉斯

回答by Igor Brejc

Try turning off the "Enable property evaluation…” setting in Debugger options, it should make debugging much faster (read more: Fix: Make Debugging Faster with Visual Studio):

尝试关闭调试器选项中的“启用属性评估...”设置,它应该使调试更快(阅读更多:修复:使用 Visual Studio 使调试更快):

alt text
(source: flickr.com)

替代文字
(来源:flickr.com

回答by Muhammad Mubashir

Disable Show Threads in Source in Visual Studio. and Close Call Stack Trace Window.

在 Visual Studio 中禁用在源中显示线程。并关闭调用堆栈跟踪窗口。

Disable Show Threads In Source. after Press debug Button

禁用在源中显示线程。 按下调试按钮后

回答by zergusik

In addition to all issues mentioned above.

除了上面提到的所有问题。

A "Disassembly" tab (opened in a background) slows down the debugging by 1-2 sec per step. (Not sure if it always happens like this).

“反汇编”选项卡(在后台打开)会使调试速度每步减慢 1-2 秒。(不确定它是否总是这样发生)。

回答by user2239903

I had the same issue, especially when debugging apps with many threads.

我遇到了同样的问题,尤其是在调试具有多个线程的应用程序时。

It was caused by the feature "Show threads in source".

这是由“在源中显示线程”功能引起的。

See the following link for details:

详情请参阅以下链接:

Code Project: Show threads in source

代码项目:在源代码中显示线程

Visual Studio Single Step Performance Fixes

Visual Studio 单步性能修复

After disabling this feature, problem has been fixed.

禁用此功能后,问题已得到解决。

回答by Bruce Dawson

There are many things that can cause Visual Studio to be slow. Excessive breakpoints and Show Threads in Source are probably the two most common, but you don't care what is most common, you care what is making Visual Studio slow for*you*.

有很多事情会导致 Visual Studio 变慢。过多的断点和在源代码中显示线程可能是最常见的两种,但您并不关心什么是最常见的,您关心的是什么让 Visual Studio*你*来说变慢

So, if deleting breakpoints and turning off Show Threads in Source doesn't work then you need to profile Visual Studio. That lets you find performance problems that are unique to your situation. An explanation of how to do this (which resolved two separate Visual Studio performance problems) can be found here:

因此,如果删除断点并关闭在源中显示线程不起作用,那么您需要分析 Visual Studio。这使您可以找到针对您的情况所特有的性能问题。可以在此处找到有关如何执行此操作的说明(解决了两个单独的 Visual Studio 性能问题):

http://randomascii.wordpress.com/2013/03/03/visual-studio-single-step-performance-fixes/

http://randomascii.wordpress.com/2013/03/03/visual-studio-single-step-performance-fixes/

More investigations of performance problems in other people's code are detailed here:

其他人代码中性能问题的更多调查在这里有详细说明:

http://randomascii.wordpress.com/category/investigative-reporting/

http://randomascii.wordpress.com/category/investigative-reporting/

回答by Pavel P

Accepted answer is hardly relevant or helpful!

接受的答案几乎不相关或有帮助!

These are some possible issues that could make debugging extremely slow:

以下是一些可能导致调试速度极慢的问题:

  • "Show threads in source" (see screensht). If you have a heavily mutithreaded app you won't be able to debug with this option enabled. What this options does is it tries to show in the same file execution position of other threads if they also execute the same code. So, if you have many threads debugger needs to check for all threads where they are located. If you have many threads this might make each step with debugger extremely slow. enter image description here
  • Many conditional or even regular breakpoints. Especially if these are in some inline functions of some header file.
  • "Show external code" enabled in call stack also makes it slower.
  • “在源代码中显示线程”(参见屏幕截图)。如果您有一个高度多线程的应用程序,您将无法在启用此选项的情况下进行调试。这个选项的作用是,如果其他线程也执行相同的代码,它会尝试在其他线程的相同文件执行位置显示。因此,如果您有许多线程,调试器需要检查它们所在的所有线程。如果您有很多线程,这可能会使调试器的每一步都非常慢。 在此处输入图片说明
  • 许多条件断点甚至常规断点。特别是如果这些在某些头文件的某些内联函数中。
  • 在调用堆栈中启用的“显示外部代码”也会使其变慢。

回答by baronvonmike

Disable “Show Threads in Source” if it is enabled, and also close the Parallel Stacks Threads, Tasks, and GPU threads windows if it they are open. Those cause the debugger to walk the call stack for every thread in the process.

如果启用,请禁用“在源中显示线程”,如果并行堆栈线程、任务和 GPU 线程窗口打开,则关闭它们。这些会导致调试器为进程中的每个线程遍历调用堆栈。

enter image description here

在此处输入图片说明

回答by Michael Petrotta

Here's a link to some guidance on Mike Stahl's MSDN blog, with respect to resolving debugger slowdowns

这是 Mike Stahl 的 MSDN 博客上有关解决调试器减速问题的一些指南的链接

I ran across this because conditional breakpoints in my app's hotspot killed my debug performance. Personal BKM: resolve potential performance issues before you leave for the night, for you may not remember them in the morning.

我遇到了这个问题,因为我的应用程序热点中的条件断点杀死了我的调试性能。个人 BKM:在您晚上离开之前解决潜在的性能问题,因为您可能在早上不记得它们。