Use this forum to read, ask or inform about memory issues in the .NET Framework and third party components.
- Joined:Fri Jun 03, 2011 4:44 am
Plugin that contains an ActiveX control causes memory leak
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);
string objectType = oType.Namespace + "." + oType.Name;
item.Tag = new ControlRecClass(pathToAssembly, objectType, videoCtrl);
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
- Joined:Wed Mar 02, 2005 7:53 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.
SciTech Software AB
Users browsing this forum: No registered users and 2 guests