Garbage collection was caused by the initialization of the WPF icon. When I removed the icon property from xaml:
<Window ... Icon="/CommonUI;component/Common/ProgressReporting/MyIcon.ico">
and instead initialized it in the constructor:
public ProgressWindow() { InitializeComponent(); Icon = Properties.Resources.MyIcon.ToImageSource(); }
the problem is gone.
The difference is that System.Window.UpdateIcon() no longer called during ShowDialog() . The UpdateIcon() call created a CachedBitmap for each image size in the icon file, which in turn called MemoryPressure.Add , and due to the high memory load, the application called GC.Collect for each new bitmap created.
This small change reduced the loading time of my progress dialog by 15 seconds when a large project is uploaded to the app!
Kim Jan 30 '13 at 13:40 2013-01-30 13:40
source share