Skip to content

Commit d8648ee

Browse files
authored
Update dotnet-alloc-tool.md
1 parent 5ebd445 commit d8648ee

File tree

1 file changed

+87
-44
lines changed

1 file changed

+87
-44
lines changed

docs/profiling/dotnet-alloc-tool.md

Lines changed: 87 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,86 +12,129 @@ ms.workload:
1212
---
1313

1414

15-
# Analyze memory usage using the .NET Object Allocation tool
15+
# Analyze memory usage by using the .NET Object Allocation tool
1616

17-
You can see how much memory your app is using and what code paths allocate the most memory using the .NET Object Allocation tool.
17+
You can see how much memory your app uses and what code paths allocate the most memory by using the .NET Object Allocation tool.
1818

19-
After running the tool, you can see the function execution paths where objects are being allocated so that you can trace back to the root of the call tree that is taking up the most amount of memory.
19+
After running the tool, you can see the function execution paths where objects are being allocated. You can then trace back to the root of the call tree that is taking up the most memory.
2020

2121
## Setup
2222

23-
1. Open the Performance Profiler (**Alt + F2)** in Visual Studio.
24-
2. Select the **.NET Object Allocation Tracking** checkbox.
23+
1. Select **Alt+F2** to open the performance profiler in Visual Studio.
2524

26-
![Diag Hub](../profiling/media/diaghub.png "Diag Hub")
25+
1. Select the **.NET Object Allocation Tracking** check box.
2726

28-
> [!NOTE]
29-
> The startup project is selected as the **Analysis Target** by default, but this can be changed to the running process, executables, running apps, and installed apps by opening the **Change Target** dropdown menu and then selecting from the available options.
27+
![The Dotnet Object Allocation Tracking tool selected](../profiling/media/dotnetalloctoolselected.png "The Dotnet Object Allocation Tracking tool selected")
3028

31-
The .NET Object Allocation tool does not currently support executables via the dropdown menu. You will have to go through the exe project system to use the tool. To do this close your current solution (**File** -> **Close Solution**) and then hit **File** -> **Open a project or solution** -> select your .exe file.
29+
1. Select the **Start** button to run the tool.
3230

33-
![Analysis Target](../profiling/media/analysistarget.png "Analysis Target")
31+
1. After the tool starts running, go through the scenario you want to profile in your app. Then select **Stop collection** or close your app to see your data.
3432

35-
3. Click the **Start** button to run the tool.
33+
![A window showing Stop collection](../profiling/media/stopcollectionlighttheme.png "A window showing Stop collection")
3634

37-
![Stop Collection](../profiling/media/stopcollection.png "Stop Collection")
35+
1. Select the **Allocation** tab. Window contents similar to the following screenshot appear.
3836

39-
4. Once the tool starts running, go through the desired scenario in your app, then press **Stop Collection** or close your app to see your data.
40-
5. Click on the **Allocation** tab and you should see an image similar to the one shown below.
37+
![The Allocation tab](../profiling/media/allocationview.png "The Allocation tab")
4138

42-
![Allocation](../profiling/media/allocation.png "Allocation")
39+
You can now analyze the memory allocation of the objects.
4340

44-
Congrats! You can now analyze the memory allocation of the objects.
41+
During collection, the tracking tool can slow down the profiled app. If performance of the tracking tool or the app is slow, and if you don't need to track every object, you can adjust the sampling rate. To do so, select the gear symbol next to the tracking tool in the profiler summary page.
4542

46-
## Understand Your Data
43+
![Settings for the Dotnet Allocation tool](../profiling/media/dotnetallocsettings.png "Settings for the Dotnet Allocation tool")
4744

48-
### Collection
45+
Adjust the sampling rate to the rate you want. This change helps speed up performance of your app during collection and analysis.
4946

50-
![Collection](../profiling/media/collection.png "Collection")
47+
![An adjusted sampling rate](../profiling/media/adjustedsamplingratedotnetalloctool.png "An adjusted sampling rate")
5148

52-
The collection view allows you to see how many objects were collected during garbage collection and how many were retained. This view also provides a few pie charts to visualize collected and survived objects by type.
49+
For more information on how to make the tool more efficient, see [Optimizing Profiler settings](../profiling/optimize-profiler-settings.md).
5350

54-
- The **Collected** column shows the number of objects that the garbage collector collected.
55-
- The **Survived** column shows the number of objects that survived after the garbage collector was run.
51+
## Understand your data
52+
53+
![A graph for the Dotnet Allocation tool](../profiling/media/graphdotnetalloc.png "A graph for the Dotnet Allocation tool")
54+
55+
In the preceding graphical view, the top graph shows the number of live objects in your app. The bottom **Object delta** graph shows the percentage change of app objects. Red bars denote when garbage collection took place.
56+
57+
![A filtered graph of the Dotnet Allocation time](../profiling/media/graphdotnetalloctimefiltered.png "A filtered graph of the Dotnet Allocation time")
58+
59+
You can filter the tabular data to display activity for only a specified time range. You can also zoom into or out of the graph.
5660

5761
### Allocation
5862

59-
![Allocation Expanded](../profiling/media/allocationexpanded.png "Allocation Expanded")
63+
![The Allocation view expanded](../profiling/media/allocationexpandedlight.png "The Allocation view expanded")
64+
65+
The **Allocation** view shows the location of objects that are allocating memory and how much memory those objects are allocating.
66+
67+
- The **Type** column is a list of classes and structures that take up memory. Double-click a type to view its backtrace as an inverted call tree. In the **Allocation** view only, you can see items within the selected category that take up memory.
68+
69+
- The **Allocations** column shows the number of objects that take up memory within a particular allocation type or function. This column appears only in the **Allocation****Call Tree**, and **Functions** views.
70+
71+
- The **Bytes** and **Average Size (Bytes)** columns don't appear by default. To show them, right-click the **Type** or **Allocations** column, and then select the **Bytes** and **Average Size (Bytes)** options to add them to the chart.
72+
73+
The two columns are similar to **Total (Allocations)** and **Self (Allocations)**, except they show the amount of memory taken up instead of the number of objects taking up memory. These columns appear only in the **Allocation** view.
74+
75+
- The **Module name** column shows the module that contains the function or process that is calling.
76+
77+
All of these columns are sortable. For the **Type** and **Module Name** columns, you can sort items alphabetically in either ascending or descending order. For **Allocations**, **Bytes** and **Average Size (Bytes)**, you can sort items by increasing or decreasing numeric value.
6078

61-
The allocation view allows you to see the location of objects that are allocating memory and how much memory those objects are allocating.
79+
#### Symbols
6280

63-
- The **Name** column is a list of various classes and structures that are taking up memory. Each item within the column is a node that can be expanded if there are items within that category taking up memory. (**Allocation** view only)
64-
- The **Total (Allocations)** column shows the number of objects within a particular allocation type that are taking up memory. (**Allocation**, **Call Tree**, and **Functions** View)
65-
- The **Self (Allocations)** column shows the number of objects within an individual item that is taking up memory. (**Allocation**, **Call Tree**, and **Functions** View)
66-
- All three of these columns are sortable. In the case of the **Name** column, the items are sorted alphabetically (either forward or backwards). For **Total** and **Self (Allocations)**, you can sort numerically (either increasingly or decreasingly).
67-
- The **Total Size (Bytes)** and **Self Size (Bytes)** columns are not on by default. To enable them, right click on the **Name**, **Total** or **Self (Allocations)** columns and then click **Total Size** and **Self Size** options to add them to the chart. The two columns are similar to **Total (Allocations)** and **Self (Allocations)** except that instead of showing the number of objects taking up memory, they show the total amount of memory in bytes that those objects are taking up. [Allocation view only]
81+
The following symbols appear in the **Allocation**, **Call Tree**, and **Functions** tabs:
82+
83+
- ![The value type symbol](../profiling/media/valuetypeicon.png "The value type symbol") - A value type like integer
84+
85+
- ![The value-type collection symbol](../profiling/media/valuetypecollectionicon.png "The value-type collection symbol") - A value-type collection like array of integers
86+
87+
- ![The reference type symbol](../profiling/media/referencetypeicon.png "The reference type symbol") - A reference type like string
88+
89+
- ![The reference-type collection symbol](../profiling/media/referencetypecollectionicon.png "The reference-type collection symbol") - A reference-type collection like array of strings
6890

6991
### Call Tree
7092

71-
![Call Tree](../profiling/media/calltree.png "Call Tree")
93+
![The Call Tree view](../profiling/media/calltreelight.png "The Call Tree view")
7294

73-
The **Call Tree** view allows you to see the function execution paths that contain objects allocating a lot of memory.
95+
The **Call Tree** view shows the function execution paths that contain objects allocating much memory.
7496

75-
- The **Function name** column shows the process or name of the function containing objects allocating memory based on the level of the node you are inspecting.
76-
- The **Total** and **Self (Allocations)** columns show the same information as the **Allocation** view.
77-
- The **Module name** column shows the module that contains the function or process that is calling.
97+
- The **Function Name** column shows the process or name of the function containing objects that allocate memory. The display is based on the level of the node you're inspecting.
98+
- The **Total (Allocations)** and **Total Size (Bytes)** columns show the number of allocated objects and the amount of memory that is used by a function and all other functions it calls.
99+
- The **Self (Allocations)** and **Self-Size (Bytes)** columns show the number of allocated objects and the amount of memory that is used by a single selected function or allocation type.
100+
- The **Average Size (Bytes)** column shows the same information as it does in the **Allocations** view.
101+
- The **Module name** column shows the module that contains the function or process that is calling.
78102

79-
![Hot Path](../profiling/media/hotpath.png "Hot Path")
103+
![A hot path expanded](../profiling/media/hotpathlight.png "A hot path expanded")
80104

81-
- The **Expand Hot Path** button highlights a function execution pathway that contains a lot of objects that are allocating memory. The algorithm starts at a user-selected node of interest and highlights the path of most allocations, guiding a user in their investigation.
82-
- The **Show Hot Path** button toggles on or off the flame icons that indicate which node are a part of the **Hot Path**.
105+
- The **Expand Hot Path** button highlights a function execution pathway that contains many objects that are allocating memory. The algorithm starts at a node you select and highlights the path of the most allocations, guiding you in your investigation.
106+
- The **Show Hot Path** button shows or hides the flame symbols that indicate which nodes are part of the hot path.
83107

84108
### Functions
85109

86-
![Functions](../profiling/media/functions.png "Functions")
110+
![The Functions view](../profiling/media/functionslight.png "The Functions view")
87111

88112
The **Functions** view shows processes, modules, and functions that are allocating memory.
89113

90-
- The **Name** column shows processes as the highest-level nodes. Underneath processes are modules, and under modules are functions.
91-
- The **Total** and **Self (Allocations)** columns show the same information as the **Allocation** view.
114+
- The **Name** column shows processes as the highest-level nodes. Underneath processes are modules, and underneath modules are functions.
115+
- These columns show the same information as they do in the **Allocation** and **Call tree** views:
116+
117+
- **Total (Allocations)**
118+
- **Self (Allocations)**
119+
- **Total Size (Bytes)**
120+
- **Self Size (Bytes)**
121+
- **Average Size (Bytes)**
122+
123+
### Collection
124+
125+
![The Collection view](../profiling/media/collectionlight.png "The Collection view")
126+
127+
The **Collection** view shows how many objects were collected or retained during garbage collection. This view also shows pie charts to visualize collected and survived objects by type.
128+
129+
- The **Collected** column shows the number of objects that the garbage collector collected.
130+
- The **Survived** column shows the number of objects that survived after the garbage collector was run.
131+
132+
### Filtering tools
133+
134+
The **Allocations**, **Call Tree**, and **Functions** views all contain the **Show Just My Code** and **Show Native Code** options and a filter box.
92135

93-
The **Allocations**, **Call Tree**, and **Functions** views all contain the **Show Just My Code**, **Show Native Code**, and **Search** options:
136+
![The filter bar](../profiling/media/filterbar.png "The filter bar")
94137

95-
- **Show Just My Code** collapses systems, frameworks, and other non-user code and into **[External Code]** frames so that user-code can be focused on. For more information, see [Debug user code with Just My Code](../debugger/just-my-code.md).
96-
- **Show Native Code** shows native code within the analysis target including non-user code if selected.
97-
- The **Filter box** allows you to filter down the **Name** or **Function name** column based on the parameter you provide. Simply type in the field and the table should filter down to show only types that contain the string provided.
138+
- **Show Just My Code** collapses systems, frameworks, and other nonuser code into **[External Code]** frames so that you can focus on just your code. For more information, see [Debug user code with Just My Code](../debugger/just-my-code.md).
139+
- **Show Native Code** shows native code within the analysis target and can include nonuser code.
140+
- With the filter box, you can filter down the **Name** or **Function name** column based on the value you provide. Enter a string value in the box. The table then shows only types that contain that string.

0 commit comments

Comments
 (0)