I\'m having a strange memory leak using element host on windows forms. I have a main form, which opens another form, the one that only haves the elementhost control on it (which
I have a WPF ElementHost
Object on my form and noticed a memory leak as well. What I was doing was something like this:
VAR cnt=this.MyHostControl.Child as MyWPFControl.WPObject;
and would do this in scope IE:
Private void Myfunction()
{
VAR cnt=this.MyHostControl.Child as MyWPFControl.WPObject;
cnt.Myproerty="Issue";
}
Not being a big fan of a VAR
(Reminds of old COM days), I decided to create a global object like this:
MyWPFControl.WPObject cnt = null;
Then on the FormLoad_EvenT()
I initialized the object cnt
like so:
cnt = this.MyHostControl.Child as MyWPFControl.WPObject;
Now my reference looks like this:
Private void Myfunction()
{
cnt=this.MyHostControl.Child as MyWPFControl.WPObject;
cnt.Myproerty="Issue";
}
And I do not need to create a var
object.
Still testing and it looks like it maybe working. We will see over time.