Memory Leak in WPF cause of System.Windows.Forms.Integration.AvalonAdapter
Running ANTS Memory Profiler on my WPF application shows a path开发者_如何学运维 to memory leak which goes through System.Windows.Forms.Integration.AvalonAdapter
:
GC...--> WPF User Control --> System.Windows.Forms.Integration.AvalonAdapter --> System.Windows.Media.ImageBrush --> System.Windows.Media.Imaging.BitmapImage --> System.IO.MemoryStream --> System.Byte[]
Has anyone any idea about what this System.Windows.Forms.Integration.AvalonAdapter
points to?
What exactly do you want to know? It is an internal class that is used by ElementHost
and two other internal classes (ElementHostAutomationPeer
and ElementHostPropertyMap
).
Weird nobody finished answering here.
Yes, if you host a wpf control in an ElementHost, AvalonAdapter will create a Bitmap for the background of the control. While this is not technically a memory leak, it does take up a surprising amount of memory (Bitmaps are heavy).
This doesn't happen if you're not hosting.
I haven't yet discovered if there's a workaround (other than stop hosting).
精彩评论