I have the following function in a COM dll (C#, .NET framework v2):
public void Leak(object jsObject) {
Type comType;
IDispatch disp = (IDispatch)jsObject;
disp.GetTypeInfo(0, 0, out comType); // this line causes the leak
Marshal.FinalReleaseComObject(disp);
Marshal.FinalReleaseComObject(jsObject);
disp = null;
jsObject = null;
GC.Collect(); GC.WaitForPendingFinalizers();
}
When calling this function repeatedly from a JScript, it leaks lots of memory:
var util = new ActiveXObject('MyLeakyCOM.MyLeakyCOM');
for(var i = 0; i < 1000; i++) {
util.Leak({});
}
I've already tried to release the object with while(Marshal.ReleaseComObject(disp) > 0) {}
but also no luck.