Plugin that contains an ActiveX control causes memory leak

Use this forum to read, ask or inform about memory issues in the .NET Framework and third party components.

Moderator: SciTech Software

Plugin that contains an ActiveX control causes memory leak

Postby think1stsolutions » Fri Jun 03, 2011 5:16 am

I am trying to get to the root cause why a simple plugin I developed in .NET 2.0 is remaining in memory. My plugin is called by an application that loads it just to show some information regarding the plugin in a list box. It seems like the app, loads and release everything properly, but using Memprofiler 4.0 it looks like a AxHost.AxContainer is the root path that is holding onto the object instance of my plugin. In the code below videoCtrl is the my plugin.

Anyone have any insight as to why my plugin object does not get disposed if the videoCtrl.IsStatic= false in the code snippet below? There should be no references to my plugin after the Foo method returns.

Code: Select all

Private void Foo()
{
      IVideoControl videoCtrl = this.VideoControlFromAssembly(type2, type, assembly);
      this.AddToListAssemblyInfo(videoCtrl, info3.FullName, type, assembly.GetName().Version.ToString());

}

private void AddToListAssemblyInfo(IVideoControl videoCtrl, string pathToAssembly, Type oType, string version)
{
    if (videoCtrl != null)
    {
        ListViewItem item = this.lvControls.Items.Add(oType.Name);
        item.SubItems.Add(videoCtrl.IsStatic.ToString());
        item.SubItems.Add(videoCtrl.VideoType);
        string objectType = oType.Namespace + "." + oType.Name;
        if (videoCtrl.IsStatic)
        {
            item.Tag = new ControlRecClass(pathToAssembly, objectType, videoCtrl);
        }
        else
        {
            item.Tag = new ControlRecClass(pathToAssembly, objectType, null);
        }
        this._logger.Log("Plugin found: " + objectType + ", Video type: " + videoCtrl.VideoType.ToUpperInvariant() + ", Version: " + version, Color.LightGreen);
    }
}


The Instance graph looks like

http://dl.dropbox.com/u/1922033/InstanceGraph.jpg
think1stsolutions
 
Posts: 1
Joined: Fri Jun 03, 2011 4:44 am

Re: Plugin that contains an ActiveX control causes memory le

Postby Andreas Suurkuusk » Mon Jun 06, 2011 9:38 pm

I'm sorry for the delay, we have had a few days of holiday in Sweden.

The instance graph suggests that you have two main things that keep your CostarDVRPlugin instance alive. First you seem to have an active timer, handled by the plugin instance. Furthermore, the instance is rooted by an ActiveX container, and some other ActiveX related instances.

From the code you supplied, it is not possible to find out why these root references are not removed. I assume that the IVideoControl instance that is created by the VideoControlFromAssembly method is the same as the CostarDVRPlugin instance in the graph. My guess then would be that the CostarDVRPlugin instance has to be disposed to remove the timer and ActiveX container references. Or, if it's your code that has added the timer and ActiveX container, make sure that you dispose the timer and the container in the Dispose method of CostarDVRPlugin.
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
 
Posts: 961
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden


Return to Known Memory Issues

Who is online

Users browsing this forum: No registered users and 2 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.


SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla
Sweden


E-mail: mail@scitech.se

Telephone: +46-706868081

cron