Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
strauss_d_getting_started_with_visual_studio_2022_learning_a.pdf
Скачиваний:
123
Добавлен:
26.06.2023
Размер:
17.04 Mб
Скачать

Chapter 3 Debugging Your Code

Memory Usage

Visual Studio Diagnostic Tools allows developers to see what the change in memory usage is. This is done by taking snapshots. When you start debugging, place a breakpoint on a method you suspect is causing a memory issue. Then you step over the method and place another breakpoint. An increase is indicated with a red up arrow as seen in Figure 3-44.

This is often the best way to analyze memory issues. Two snapshots will give you a nice diff and allow you to see exactly what has changed.

Figure 3-44.  Memory usage snapshots

You can also compare two snapshots by clicking one of the links in the memory usage snapshots (Figure 3-44) and viewing the comparison in the snapshot window that opens (Figure 3-45). By selecting a snapshot in the Compare to drop-down list, you can see what has changed.

199

Chapter 3 Debugging Your Code

Figure 3-45.  Comparing snapshots

The Events View

As you step through your application, the Events view will show you the different events that happen during your debug session. This can be setting a breakpoint or stepping through code. It also shows you the duration of the event as seen in Figure 3-46.

Figure 3-46.  The Events view

200

Chapter 3 Debugging Your Code

This means that as you step through your code, the Events tab will display the time the code took to run from the previous step operation to the next. You can also see the same events displayed as PerfTips in the Visual Studio code editor as seen in Figure 3-47.

Figure 3-47.  PerfTips in the code editor

IntelliTrace events are available in this tab if you have Visual Studio Enterprise.

For a comparison of the Visual Studio 2022 Editions, head on over to https:// visualstudio.microsoft.com/vs/compare/ and see what each edition has to offer.

PerfTips allows developers to quickly identify potential issues in your code.

The Right Tool for the Right Project Type

Table 3-1 shows which tools Visual Studio offers and the project types that can make use of these tools.

201