-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathMemoryContent.xaml
More file actions
240 lines (231 loc) · 16.9 KB
/
MemoryContent.xaml
File metadata and controls
240 lines (231 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<UserControl x:Class="PerformanceMonitorDashboard.Controls.MemoryContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
xmlns:controls="clr-namespace:PerformanceMonitorDashboard.Controls"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1200">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Themes/DarkTheme.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- Context Menu for DataGrid Copy/Export -->
<ContextMenu x:Key="DataGridContextMenu">
<MenuItem Header="Copy Cell" Click="CopyCell_Click">
<MenuItem.Icon><TextBlock Text="📋"/></MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy Row" Click="CopyRow_Click">
<MenuItem.Icon><TextBlock Text="📄"/></MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy All Rows" Click="CopyAllRows_Click">
<MenuItem.Icon><TextBlock Text="📑"/></MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem Header="Export to CSV..." Click="ExportToCsv_Click">
<MenuItem.Icon><TextBlock Text="📊"/></MenuItem.Icon>
</MenuItem>
</ContextMenu>
<Style x:Key="DefaultRowStyle" TargetType="DataGridRow">
<Setter Property="ContextMenu" Value="{StaticResource DataGridContextMenu}"/>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<TabControl TabStripPlacement="Top" Margin="0,5,0,0">
<!-- Memory Overview Sub-Tab -->
<TabItem Header="Memory Overview">
<!-- Chart + Summary Panel (grid removed) -->
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Memory Usage Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
<ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryStatsOverviewChart"/>
<!-- Summary Panel with absolute GB values and pressure status -->
<Border Grid.Row="2" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Padding="10,6">
<WrapPanel HorizontalAlignment="Center">
<!-- Physical Memory -->
<StackPanel Orientation="Horizontal" Margin="0,0,24,0">
<TextBlock Text="Physical Memory:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsPhysicalText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
<!-- SQL Server Memory (committed) -->
<StackPanel Orientation="Horizontal" Margin="0,0,24,0">
<TextBlock Text="SQL Server Memory:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsSqlServerText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
<!-- Target Memory -->
<StackPanel Orientation="Horizontal" Margin="0,0,24,0">
<TextBlock Text="Target Memory:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsTargetText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
<!-- Buffer Pool -->
<StackPanel Orientation="Horizontal" Margin="0,0,24,0">
<TextBlock Text="Buffer Pool:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsBPPercentText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
<!-- Plan Cache -->
<StackPanel Orientation="Horizontal" Margin="0,0,24,0">
<TextBlock Text="Plan Cache:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsPCPercentText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
<!-- Utilization -->
<StackPanel Orientation="Horizontal" Margin="0,0,24,0">
<TextBlock Text="Utilization:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsUtilPercentText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
<!-- Pressure -->
<StackPanel Orientation="Horizontal">
<TextBlock Text="Pressure:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryStatsPressureText" Text="None" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
</WrapPanel>
</Border>
</Grid>
</Border>
</TabItem>
<!-- Memory Grants Sub-Tab -->
<TabItem Header="Memory Grants">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Chart 1: Memory Grant Sizing -->
<Border Grid.Row="0" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5,5,5,2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Memory Grant Sizing Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
<ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryGrantSizingChart"/>
<TextBlock x:Name="MemoryGrantSizingNoData" Grid.Row="1" Style="{StaticResource EmptyStateMessage}"
Text="No memory grant data in selected time range"/>
<controls:LoadingOverlay x:Name="MemoryGrantSizingLoading" Grid.Row="1"/>
</Grid>
</Border>
<!-- Chart 2: Memory Grant Activity -->
<Border Grid.Row="1" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5,2,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Memory Grant Activity Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
<ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryGrantActivityChart"/>
<TextBlock x:Name="MemoryGrantActivityNoData" Grid.Row="1" Style="{StaticResource EmptyStateMessage}"
Text="No memory grant data in selected time range"/>
<controls:LoadingOverlay x:Name="MemoryGrantActivityLoading" Grid.Row="1"/>
</Grid>
</Border>
</Grid>
</TabItem>
<!-- Memory Clerks Sub-Tab -->
<TabItem Header="Memory Clerks">
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Clerk Type Picker -->
<Border Grid.Column="0" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,1,0" Padding="8">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Select Memory Clerks" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundBrush}" Margin="0,0,0,4"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,4">
<Button Content="Top Clerks" Click="MemoryClerkSelectTop_Click" Padding="6,2" Margin="0,0,4,0" FontSize="11"/>
<Button Content="Clear All" Click="MemoryClerkClearAll_Click" Padding="6,2" FontSize="11"/>
<TextBlock x:Name="MemoryClerkCountText" Text="0 selected" FontSize="10" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="8,0,0,0"/>
</StackPanel>
<TextBox Grid.Row="2" x:Name="MemoryClerkSearchBox" TextChanged="MemoryClerkSearch_TextChanged"
Margin="0,0,0,4" Padding="4,2"/>
<ListBox Grid.Row="3" x:Name="MemoryClerksList" Background="Transparent" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}"
Checked="MemoryClerk_CheckChanged" Unchecked="MemoryClerk_CheckChanged"
Foreground="{DynamicResource ForegroundBrush}" FontSize="11">
<TextBlock Text="{Binding DisplayName}"/>
</CheckBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
<!-- Chart + Summary -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Memory Clerks Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
<ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryClerksChart"/>
<!-- Summary Panel (excludes buffer pool) -->
<Border Grid.Row="2" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Padding="10,8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Non-BP Total:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryClerksTotalText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
<TextBlock Text="Top Non-BP Clerk:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="MemoryClerksTopText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<TextBlock x:Name="MemoryClerksNoDataMessage" Grid.Row="1" Style="{StaticResource EmptyStateMessage}"
Text="No memory clerk data in selected time range"/>
<controls:LoadingOverlay x:Name="MemoryClerksLoading" Grid.Row="1"/>
</Grid>
</Grid>
</Border>
</TabItem>
<!-- Plan Cache Sub-Tab -->
<TabItem Header="Plan Cache">
<!-- Plan Cache Chart -->
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Plan Cache Size (Single-Use vs Multi-Use)" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
<ScottPlot:WpfPlot Grid.Row="1" x:Name="PlanCacheChart"/>
<!-- Summary Panel for stability metrics -->
<Border Grid.Row="2" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Padding="10,8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Total Plans:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="PlanCacheTotalPlansText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
<TextBlock Text="Oldest Plan Age:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock x:Name="PlanCacheOldestPlanText" Text="N/A" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Border>
</TabItem>
<!-- Memory Pressure Events Sub-Tab -->
<TabItem Header="Memory Pressure Events">
<!-- Memory Pressure Events Chart -->
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Memory Pressure Events Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
<ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryPressureEventsChart" Margin="5"/>
</Grid>
</Border>
</TabItem>
</TabControl>
</UserControl>