Arpit Khandelwal
Arpit Khandelwal

Reputation: 1803

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?

Upvotes: 3

Views: 1801

Answers (2)

Benjol
Benjol

Reputation: 66531

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).

Upvotes: 1

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174299

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).

Upvotes: 1

Related Questions