This code shouldn't be causing any leaks in itself.
In general, the RCW does AddRef during its construction, and the Release is
called during finalization. No AddRef is performed by .NET when you call
methodCall. You shouldn't even need to call Marshal.FinalReleaseComObject
because when the garbage collector collects your RCWs the underlying COM
references will be released.
Now, if your implementation wrapper.methodCall performs AddRef, then that
may be where you are leaking. Circular references in COM are known to be an
issue. Are the COM classes yours or are they third party?
Adam
> Hi,
>
[quoted text clipped - 23 lines]
> Marshal.FinalReleaseComObject(wrapper);
> wrapper = null;
Christian Fröschlin - 31 Mar 2008 10:37 GMT
> methodCall. You shouldn't even need to call Marshal.FinalReleaseComObject
> because when the garbage collector collects your RCWs the underlying COM
> references will be released.
However, explicit releasing may be preferrable if the COM object
uses a lot of native resources which the GC knows nothing about,
otherwise, the GC may not start collecting early enough.