Share via


WPF based application experiences different memory leaks.

If you have a WPF based application which leaks memory with following symptoms, the fix is available now. This fix as on 31/ 3/ 2010 is the latest. This is fixing for about 5 different unrelated and extremely rare intermittent memory leaks in WPF. I will release the KB soon. I filled fix only for.net 3.5 SP1 and some of the issues are there in 4.0 as well. I will add the build numbers and KB number once it is public. If you happen to be running to this issue feel free to contact me via support.microsoft.com.

Memory is used in VAD and not native heap.

0:004> !address -summary

-------------------- Usage SUMMARY --------------------------

    TotSize ( KB) Pct(Tots) Pct(Busy) Usage

   2d087000 ( 737820) : 00.01% 73.08% : RegionUsageIsVAD

   7ffc25f6000 (8588924888) : 99.99% 00.00% : RegionUsageFree

    7c56000 ( 127320) : 00.00% 12.61% : RegionUsageImage

     810000 ( 8256) : 00.00% 00.82% : RegionUsageStack

      12000 ( 72) : 00.00% 00.01% : RegionUsageTeb

    84f6000 ( 136152) : 00.00% 13.49% : RegionUsageHeap

          0 ( 0) : 00.00% 00.00% : RegionUsagePageHeap

       1000 ( 4) : 00.00% 00.00% : RegionUsagePeb

       2000 ( 8) : 00.00% 00.00% : RegionUsageProcessParametrs

       2000 ( 8) : 00.00% 00.00% : RegionUsageEnvironmentBlock

       Tot: 7ffffff0000 (8589934528 KB) Busy: 000000003d9fa000 (1009640 KB)

-------------------- Type SUMMARY --------------------------

    TotSize ( KB) Pct(Tots) Usage

   7ffc25f6000 (8588924888) : 99.99% : <free>

    7c56000 ( 127320) : 00.00% : MEM_IMAGE

    1efc000 ( 31728) : 00.00% : MEM_MAPPED

   33ea8000 ( 850592) : 00.01% : MEM_PRIVATE

-------------------- State SUMMARY --------------------------

    TotSize ( KB) Pct(Tots) Usage

   16873000 ( 369100) : 00.00% : MEM_COMMIT

   7ffc25f6000 (8588924888) : 99.99% : MEM_FREE

   27187000 ( 640540) : 00.01% : MEM_RESERVE

Largest free region: Base 000000007fff0000 - Size 00000641a8bf0000 (6717845440 KB)

System.WeakReference and System.Windows.Dependent[] seems very high.

0:004> !dumpheap -stat

total 191433 objects

Statistics:

              MT Count TotalSize Class Name

00000642801c8cf0 1 24 System.Collections.Generic.ObjectEqualityComparer`1[[System.Windows.DependencyObject, WindowsBase]]

00000642801c8890 1 24 System.Collections.Generic.ObjectEqualityComparer`1[[System.Windows.Threading.DispatcherTimer, WindowsBase]]

00000642801c7be8 1 24 System.Collections.Generic.GenericArraySortHelper`1[[MS.Internal.Shaping.OpenTypeLayoutCache+GlyphLookupRecord, PresentationCore]]

00000642801c70f8 1 24 System.Collections.Generic.ArraySortHelper`1[[MS.Internal.FontCache.FamilyCollection+PhysicalFace, PresentationCore]]

00000642801c7028 1 24 System.Collections.Generic.ObjectComparer`1[[MS.Internal.FontCache.FamilyCollection+PhysicalFace, PresentationCore]]

.

.

.

.

000006422b92a360 127 26416 System.Windows.Data.BindingExpression

000006427842dfb0 413 26432 System.EventHandler

000006422b8f0fb0 299 26760 System.Windows.ChildValueLookup[]

0000064278438880 692 27680 System.RuntimeType

000006422b8d5f78 573 32088 System.Windows.FrameworkPropertyMetadata

000006427843def8 380 33440 System.Collections.Hashtable

00000642801c11c8 860 34400 MemoryLeakTest.Entry

000006422f2e70d0 478 42064 System.Windows.DependencyProperty

000006427843e5e0 200 51200 System.Byte[]

000006427843d6c0 291 77656 System.Int32[]

000006422f2d2388 593 105032 System.Windows.EffectiveValueEntry[]

000006427843e0c0 382 237888 System.Collections.Hashtable+bucket[]

0000064278424390 1965 253016 System.Object[]

00000642784365a0 4711 313408 System.String

000006427842dab8 159901 5116832 System.WeakReference

0000000000174cd0 58 54677432 Free

000006422f2cdc90 2 66066888 System.Windows.Dependent[]

Total 191433 objects

Fragmented blocks larger than 0.5 MB:

            Addr Size Followed by

0000000024d81000 1.8MB 0000000024f44cd8 System.Windows.EventRoute

0:004> !dumpheap -type System.Windows.Dependent[]

         Address MT Size

0000000011fc8598 000006422f2cdc90 310584

00000000151e4ef8 000006422f2cdc90 65756304

total 2 objects

Statistics:

              MT Count TotalSize Class Name

000006422f2cdc90 2 66066888 System.Windows.Dependent[]

Total 2 objects

System.Windows.EffectiveValueEntry[] also has some role in the leak which is holding on to System.Windows.Dependent[])

0:004> !gcroot 00000000151e4ef8

Note: Roots found on stacks may be false positives. Run "!help gcroot" for

more info.

Scan Thread 0 OSTHread 5df4

RSP:12edd0:Root:0000000001f4c510(System.Windows.Threading.Dispatcher)->

0000000001f75048(System.Windows.Input.InputManager)->

0000000001f75d20(System.Windows.Input.StylusLogic)->

0000000001f75f18(System.Collections.Generic.Dictionary`2[[System.Object, mscorlib],[System.Windows.Input.PenContexts, PresentationCore]])->

0000000001f75f98(System.Collections.Generic.Dictionary`2+Entry[[System.Object, mscorlib],[System.Windows.Input.PenContexts, PresentationCore]][])->

0000000002042838(System.Windows.Interop.HwndSource)->

0000000001f73d78(MemoryLeakTest.Window1)->

0000000001fcea58(System.Windows.Controls.Label)->

0000000001fcaa88(System.Windows.Controls.Grid)->

0000000001fc9e88(System.Windows.Controls.Grid)->

0000000001f83d50(System.Windows.Controls.DockPanel)->

0000000001f832e8(System.Windows.Controls.DockPanel)->

0000000001f83d00(System.Windows.Controls.UIElementCollection)->

0000000001f83d28(System.Windows.Media.VisualCollection)->

0000000001fd1bf0(System.Object[])->

0000000001fcec70(System.Windows.Controls.ListBox)->

0000000001fdef00(System.Windows.EffectiveValueEntry[])->

00000000026200a0(MS.Utility.FrugalMap)->

0000000002081ca0(MS.Utility.ArrayObjectMap)->

0000000002081cc0(MS.Utility.FrugalMapBase+Entry[])->

0000000002081c88(System.Windows.DependentList)->

0000000002081d88(MS.Utility.ArrayItemList`1[[System.Windows.Dependent, WindowsBase]])->

00000000151e4ef8(System.Windows.Dependent[])

Scan Thread 2 OSTHread 575c

Scan Thread 3 OSTHread 6a5c

Scan Thread 5 OSTHread 7d18

Also another unrelated issue.

0:000> !dumpheap -stat

total 26378376 objects

Statistics:

      MT Count TotalSize Class Name

7a5ec668 1 12 System.ComponentModel.TypeConverterAttribute

7a5ec5f0 1 12 System.ComponentModel.TypeConverter

7a5ec0d8 1 12 System.ComponentModel.WeakHashtable+WeakKeyComparer

7a5eb880 1 12 System.ComponentModel.DoubleConverter

7a5eb6fc 1 12 System.ComponentModel.Int32Converter

7a5ea2a0 1 12 System.ComponentModel.StringConverter

7a5e93cc 1 12 System.Net.Cache.RequestCachePolicy

7a5e8ab0 1 12 System.Diagnostics.TraceOptions

7a5e28b4 1 12 System.Collections.Specialized.StringDictionary

7a5d61ac 1 12 System.Net.CaseInsensitiveAscii

7a5d5f10 1 12 System.Net.FileWebRequestCreator

79333ed4 1 12 System.Text.DecoderExceptionFallback

79333e90 1 12 System.Text.EncoderExceptionFallback

79331ea4 1 12 System.RuntimeTypeHandle

793316e0 1 12 System.Char

.

.

.

79332a30 35810 859440 System.Collections.ArrayList

57a0a0e0 54208 867328 System.Windows.WeakEventManager+ListenerList

57a13090 37451 898824 MS.Utility.SingleItemList`1[[System.Windows.Dependent, WindowsBase]]

55ce35ac 46274 925480 System.Windows.InstanceValueKey

55cda004 2947 943040 System.Windows.Controls.ScrollViewer

55ce975c 61024 976384 MS.Internal.Data.WeakDependencySource

55ce3290 8866 1028040 System.Windows.ContainerDependent[]

55ce90a4 35568 1138176 System.Windows.TemplateNameScope

79324338 23579 1226108 System.Collections.Generic.Dictionary`2[[System.Object, mscorlib],[System.Object, mscorlib]]

79330a00 16634 1259588 System.String

7a5ecac4 65189 1303780 System.Collections.Specialized.HybridDictionary

79324510 23575 1414500 System.Collections.Generic.Dictionary`2+Entry[[System.Object, mscorlib],[System.Object, mscorlib]][]

54f5e164 39598 1425528 MS.Utility.ThreeItemList`1[[System.Double, mscorlib]]

55cd6fa4 5897 1462456 System.Windows.Controls.Label

548178f0 16646 1464848 System.Windows.Media.GlyphRun

55cbabf4 5897 1533220 System.Windows.Controls.DockPanel

55ce7340 8855 1700220 System.Windows.PropertyValue[]

55cd1ca8 6939 1720872 System.Windows.Controls.Button

54833b6c 43199 1727960 System.Windows.Media.DoubleCollection

55ccaecc 5893 1744328 System.Windows.Controls.Primitives.ScrollBar

55cd7b4c 6959 1753668 System.Windows.Controls.ListBoxItem

57a0a12c 88932 1778640 MS.Internal.WeakEventTable+EventKey

55cc5b50 9057 1822812 MS.Utility.ItemStructMap`1+Entry[[MS.Utility.ItemStructList`1[[System.Windows.ChildValueLookup, PresentationFramework]], WindowsBase]][]

57a0fb58 77023 1848552 System.Windows.ModifiedValue

55cd7550 5896 1863136 System.Windows.Controls.ListBox

7a5ecb80 68070 1905960 System.Collections.Specialized.ListDictionary

55ce94ec 61025 1952840 MS.Internal.Data.PropertyPathWorker+SourceValueState[]

55cc8cf4 23621 2173132 System.Windows.Data.Binding

54838114 36453 2187180 System.Windows.Media.RenderData

55ce9410 61024 2196864 MS.Internal.Data.ClrBindingWorker

7a5ecc40 110449 2208980 System.Collections.Specialized.ListDictionary+DictionaryNode

55ce4ba0 9910 2695520 System.Windows.Controls.Grid

79333470 36510 2790280 System.Byte[]

79333150 13684 2800200 System.Collections.Hashtable+bucket[]

55ce9490 61025 2929200 MS.Internal.Data.PropertyPathWorker

579eff24 94488 3023616 System.Collections.Specialized.NotifyCollectionChangedEventHandler

55cb86e4 12853 3187544 System.Windows.Controls.Border

79329c6c 121018 3872576 System.EventHandler

55cc4e2c 16835 4175080 System.Windows.Controls.ContentPresenter

55cc5d2c 115754 5093528 System.Windows.ChildValueLookup[]

55cc79f4 15794 5433136 System.Windows.Controls.TextBlock

55ce35f8 61024 6590592 System.Windows.Data.BindingExpression

57a0165c 141842 18767256 System.Windows.EffectiveValueEntry[]

793041d0 378285 143217732 System.Object[]

7932a1b0 11702281 187236496 System.WeakReference

55cfed28 11193761 268650264 System.Windows.DeferredAppResourceReference

579fe0c4 2181 417178832 MS.Internal.WeakEventTable+EventKey[]