Posted 15 years ago
by Bill Boland
-
Software Engineer,
CME, Inc for Thomson Elite
Version: 9.1.0503
Platform: .NET 3.5
Environment: Windows 7 (32-bit)
We have been doing some performance and memory profiling of our application. It uses the DateTimePicker control from the WPF Studio(2009.0503). The RedGate ANTS Memory Profiler reports that windows that have a DateTimePicker control on them are not being reclaimed when closed. This causes a memory leak.
To isolate this, we created a simple WPF/.NET application that opens a window with only a single DateTimePicker control on it and then perform the memory profiling taking snapshots before opening the window, when the window is opened, and after closing the window. The profiling results from the last snapshot (compared with the first, basline snapshot) show that the window is still retained in memory.
We have documented the reference chain as reported by the ANTS Memory Profiler (see below). We also tried this with the latest version (2010.0521) and the same reference chain prevents the window from being reclaimed. If we remove the DateTimePicker from the window (essentially an empty window), the window is reclaimed as expected. So the simple inclusion of the DateTimePicker control seems to prevent the window from being reclaimed.
We can provide additional details and the sample application. Any assistance would be appreciated as the DateTimePicker control is used extensively on windows and the windows sometime hold references to large amounts of data that is not being reclaimed.
Reference Chain preventing window from being reclaimed
Finalizer Queue --> System.Windows.Documents.TextEditor _uiScope --> System.Windows.Controls.TextBox (this as DependencyObject)._effectiveValues --> System.Window.EffectiveValueEntry[] --> ActiproEditorMemoryLeak.WindowWithDateTimePicker
WindowWithDateTimePicker.xaml
To isolate this, we created a simple WPF/.NET application that opens a window with only a single DateTimePicker control on it and then perform the memory profiling taking snapshots before opening the window, when the window is opened, and after closing the window. The profiling results from the last snapshot (compared with the first, basline snapshot) show that the window is still retained in memory.
We have documented the reference chain as reported by the ANTS Memory Profiler (see below). We also tried this with the latest version (2010.0521) and the same reference chain prevents the window from being reclaimed. If we remove the DateTimePicker from the window (essentially an empty window), the window is reclaimed as expected. So the simple inclusion of the DateTimePicker control seems to prevent the window from being reclaimed.
We can provide additional details and the sample application. Any assistance would be appreciated as the DateTimePicker control is used extensively on windows and the windows sometime hold references to large amounts of data that is not being reclaimed.
Reference Chain preventing window from being reclaimed
Finalizer Queue --> System.Windows.Documents.TextEditor _uiScope --> System.Windows.Controls.TextBox (this as DependencyObject)._effectiveValues --> System.Window.EffectiveValueEntry[] --> ActiproEditorMemoryLeak.WindowWithDateTimePicker
WindowWithDateTimePicker.xaml
<Window x:Class="ActiproEditorMemoryLeak.WindowWithDateTimePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowWithDateTimePicker" Height="300" Width="300" xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared">
<Grid>
<shared:DateTimePicker Height="23" Margin="38,72,60,0" Name="dateTimePicker1" VerticalAlignment="Top" />
</Grid>
</Window>