Skip to content

Repo sync for protected branch #10032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ To avoid misplaced edits, edits from editor extensions are applied as follows:

### Asynchronous execution

[ITextViewSnapshot.GetTextDocumentAsync](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot.gettextdocumentasync#microsoft-visualstudio-extensibility-editor-itextviewsnapshot-gettextdocumentasync(system-threading-cancellationtoken)) opens a copy of the text document in the Visual Studio extension. Since extensions run in a separate process, all extension interactions are asynchronous, cooperative, and have some caveats:
[ITextViewSnapshot.GetTextDocumentAsync](/visualstudio/extensibility/visualstudio.extensibility/editor/editor-concepts?view=vs-2022#itextviewsnapshot) opens a copy of the text document in the Visual Studio extension. Since extensions run in a separate process, all extension interactions are asynchronous, cooperative, and have some caveats:

> [!CAUTION]
> `GetTextDocumentAsync` might fail if called on an old `ITextDocument`, because it may no longer be cached by the Visual Studio client, if the user has made many changes since it was created. For this reason, if you plan to store an `ITextView` to access its document later, and can't tolerate failure, it may be a good idea to call `GetTextDocumentAsync` immediately. Doing so fetches the text content for that version of the document into your extension, ensuring that a copy of that version is sent to your extension before it expires.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ A Visual Studio solution containing all samples can be found at [Samples.sln](ht
| [Markdown linter](https://github.com/microsoft/VSExtensibility/tree/main/New_Extensibility_Model/Samples/MarkdownLinter) | A complete extension with many moving parts interacting to provide an enhanced experience in the editor for a certain file type. |
| [Project Query](https://github.com/microsoft/VSExtensibility/tree/main/New_Extensibility_Model/Samples/VSProjectQueryAPISample) | Shows several different kinds of project system queries you can make. |
| [Comment remover](https://github.com/microsoft/VSExtensibility/tree/main/New_Extensibility_Model/Samples/CommentRemover) | Shows how to consume [Visual Studio SDK](https://www.nuget.org/packages/Microsoft.VisualStudio.SDK) services through .NET dependency injection and use VisualStudio.Extensibility APIs for commands, prompts and progress report. |
| [RegexMatchDebugVisualizer](https://github.com/microsoft/VSExtensibility/tree/dev/maprospe/vsix_creation/New_Extensibility_Model/Samples/RegexMatchDebugVisualizer) | Shows how to use [Remote UI](./inside-the-sdk/remote-ui.md) to create a [Debugger Visualizer](./debugger-visualizer/debugger-visualizers.md) to visualize regular expression matches that will launch in a modal dialog window. |
| [MemoryStreamDebugVisualizer](https://github.com/microsoft/VSExtensibility/tree/dev/maprospe/vsix_creation/New_Extensibility_Model/Samples/MemoryStreamDebugVisualizer) | Shows how to create a [Debugger Visualizer](./debugger-visualizer/debugger-visualizers.md) to visualize MemoryStream objects that launches in a non-modal tool window. |
| RegexMatchDebugVisualizer | Shows how to use [Remote UI](./inside-the-sdk/remote-ui.md) to create a [Debugger Visualizer](./debugger-visualizer/debugger-visualizers.md) to visualize regular expression matches that will launch in a modal dialog window. |
| MemoryStreamDebugVisualizer | Shows how to create a [Debugger Visualizer](./debugger-visualizer/debugger-visualizers.md) to visualize MemoryStream objects that launches in a non-modal tool window. |
| [RustLanguageServiceProvider](https://github.com/microsoft/VSExtensibility/tree/main/New_Extensibility_Model/Samples/RustLanguageServerProvider) | Shows how to create a Rust language server provider extension that adds Intellisense and tooltips when a rust file is opened. |

## Advanced topics
Expand Down
27 changes: 27 additions & 0 deletions docs/profiling/includes/change-diff-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Change (Diff) report
description: Change (Diff) report in the Memory Usage tool
services: ""
author: mikejo5000
ms.service: ""
ms.topic: include
ms.date: 02/06/2024
ms.author: mikejo
ms.custom: include file
---

The change report adds columns (marked with **(Diff)**) to the base report that show the difference between the base snapshot value and the comparison snapshot. Here's how a Native Type View diff report might look:

::: moniker range=">=vs-2022"

[![Screenshot of Native Types Diff View.](../media/vs-2022/dbgdiag-mem-native-types-view-diff.png "Native Types Diff View")](../media/vs-2022/dbgdiag-mem-native-types-view-diff.png#lightbox)

::: moniker-end

::: moniker range="vs-2019"

![Screenshot of Native Types Diff View.](../media/vs-2019/dbgdiag-mem-native-types-view-diff.png)

::: moniker-end

The top pane shows the count and size of the types in the snapshot, including the size of all objects that are referenced by the type (**Inclusive Size**).
47 changes: 47 additions & 0 deletions docs/profiling/includes/managed-types-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Managed Types report
description: Managed Types report in the Memory Usage tool
services: ""
author: mikejo5000
ms.service: ""
ms.topic: include
ms.date: 02/06/2024
ms.author: mikejo
ms.custom: include file
---

Choose the current link of an **Objects (Diff)** cell in the Memory Usage summary table.

::: moniker range=">=vs-2022"

[![Screenshot of managed type report.](../media/vs-2022/dbgdiag-mem-managed-types-report-paths-to-root.png "Managed type report")](../media/vs-2022/dbgdiag-mem-managed-types-report-paths-to-root.png#lightbox)

> [!NOTE]
> For .NET code, the **View Instances** icon (![The instance icon in the Object Type column](../media/dbg-mma-instances-icon.png "DBG_MMA_InstancesIcon")) is only available while using the [debugger-integrated Memory Usage tool](../../profiling/memory-usage.md) or when you open a [heap snapshot](../../debugger/using-dump-files.md) and choose **Debug Managed Memory**.

::: moniker-end

::: moniker range="vs-2019"

![Screenshot of managed type report.](../media/vs-2019/dbgdiag-mem-managed-types-report-paths-to-root.png)

::: moniker-end

The top pane shows the count and size of the types in the snapshot, including the size of all objects that are referenced by the type (**Inclusive Size**).

The **Paths to Root** tree in the bottom pane displays the objects that reference the type selected in the upper pane. The .NET garbage collector cleans up the memory for an object only when the last type that references it has been released.

::: moniker range=">=vs-2022"

The **Referenced Types** tree displays the references that are held by the type selected in the upper pane.

![Screenshot of Referenced Objects report.](../media/vs-2022/dbgdiag-mem-managed-types-report-referenced-types.png)

::: moniker-end
::: moniker range="vs-2019"

The **Referenced Types** tree displays the references that are held by the type selected in the upper pane.

![Screenshot of Referenced Objects report.](../media/vs-2019/dbgdiag-mem-managed-types-report-referenced-types.png)

::: moniker-end
25 changes: 25 additions & 0 deletions docs/profiling/includes/memory-usage-insights.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Memory Usage Insights report
description: Memory Usage Insights report in the Memory Usage tool
services: ""
author: mikejo5000
ms.service: ""
ms.topic: include
ms.date: 02/06/2024
ms.author: mikejo
ms.custom: include file
---

For managed memory, the Memory Analysis tool also gives multiple powerful built-in auto insights. Select the **Insights** tab in the Managed types reports and it shows the applicable auto insights like **Duplicate strings**, **Sparse arrays**, and **Event handler leaks**.

[![Screenshot of the insight view in the Memory Usage tool.](../media/vs-2022/dbgdiag-mem-managed-insights.png "Memory Usage insight")](../media/vs-2022/dbgdiag-mem-managed-insights.png#lightbox)

The **Duplicate Strings** section shows the list of strings that get allocated multiple times on the heap. In addition, this section shows the total wasted memory, that is, the (number of instances - 1) times the size of the string.

The **Sparse Arrays** section shows arrays that are mostly filled with zero elements, which can be inefficient in terms of performance and memory usage. The memory analysis tool will automatically detect these arrays and show you how much memory is being wasted due to these zero values.

The **Event Handler Leaks** section, available in Visual Studio 2022 version 17.9 Preview 1, shows potential memory leaks that can occur when one object subscribes to another object's event. If the publisher of the event outlives the subscriber, the subscriber remains alive, even if there are no other references to it. This can lead to memory leaks, where unused memory isn't properly freed, causing the application to use more and more memory over time.

Certain types are known to have fields that can be read to determine the size of the native memory they're holding onto. The **Insights** tab shows fake native memory nodes in the object graph, which are retained by their parent objects such that the UI will recognize them and display their size and reference graph.

[![Screenshot of the native insight view in the Memory Usage tool.](../media/vs-2022/dbgdiag-mem-native-insights.png "native insight view in the Memory Usage tool")](../media/vs-2022/dbgdiag-mem-native-insights.png#lightbox)
62 changes: 62 additions & 0 deletions docs/profiling/includes/native-types-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: Native Types report
description: Native Types report in the Memory Usage tool
services: ""
author: mikejo5000
ms.service: ""
ms.topic: include
ms.date: 02/06/2024
ms.author: mikejo
ms.custom: include file
---

Choose the current link of an **Allocations (Diff)** or **Heap Size (Diff)** cell in the Memory Usage summary table of the **Diagnostic Tools** window.

::: moniker range=">=vs-2022"

[![Screenshot of Native Type View.](../media/vs-2022/dbgdiag-mem-native-types-view.png)](../media/vs-2022/dbgdiag-mem-native-types-view.png#lightbox)

::: moniker-end
::: moniker range="<=vs-2019"

[![Screenshot of Native Type View.](../media/vs-2019/dbgdiag-mem-native-types-view.png)](../media/vs-2019/dbgdiag-mem-native-types-view.png#lightbox)

::: moniker-end

The **Types View** displays the number and size of the types in the snapshot.

::: moniker range=">=vs-2022"

- Choose the **View Instances** icon next to a selected type to display information about the objects of the selected type in the snapshot.

The **Instances** view displays each instance of the selected type. Selecting an instance displays the call stack that resulted in the creation of the instance in the **Allocation Call Stack** pane.

[![Screenshot of the Instances view and Allocation Call Stack pane.](../media/vs-2022/dbgdiag-mem-native-instances.png)](../media/vs-2022/dbgdiag-mem-native-instances.png#lightbox)

::: moniker-end

::: moniker range="<=vs-2019"

- Choose the instances icon (![The instance icon in the Object Type column](../media/dbg-mma-instances-icon.png "DBG_MMA_InstancesIcon")) of a selected type to display information about the objects of the selected type in the snapshot.

The **Instances** view displays each instance of the selected type. Selecting an instance displays the call stack that resulted in the creation of the instance in the **Allocation Call Stack** pane.

![Screenshot of the Instances view and Allocation Call Stack pane.](../media/vs-2019/dbgdiag-mem-native-instances.png)

::: moniker-end

::: moniker range=">=vs-2022"

- Choose **Stacks** to see the allocation stack for the selected type.

[![Screenshot of Stacks view.](../media/vs-2022/dbgdiag-mem-native-stacks-view.png)](../media/vs-2022/dbgdiag-mem-native-stacks-view.png#lightbox)

::: moniker-end

::: moniker range="<=vs-2019"

- Choose **Stacks View** in the **View Mode** list to see the allocation stack for the selected type.

![Screenshot of Stacks view.](../media/vs-2019/dbgdiag-mem-native-stacks-view.png)

::: moniker-end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/profiling/media/vs-2022/dbgdiag-mem-native-instances.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/profiling/media/vs-2022/dbgdiag-mem-native-stacks-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/profiling/media/vs-2022/dbgdiag-mem-native-types-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading