Memory consumption when using COM interop?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a COM DLL in my C# application (a single process).
This COM DLL generates a data array, and by using the interop DLL (generated
by VS/TlbImp.exe), I'm getting this array to a safe Array into my C# code
(using the marshaling and all that...).

My Question is:
Does a multiple data arrays is allocated when marshaling the data from the
COM component to my C# component. I mean; Does an array is allocated in the
COM side and another array in the C# side and the content is copied among
this two arrays?
Or the C# side uses the allocated array directly at the COM side?
 
Sharon said:
I'm using a COM DLL in my C# application (a single process).
This COM DLL generates a data array, and by using the interop DLL (generated
by VS/TlbImp.exe), I'm getting this array to a safe Array into my C# code
(using the marshaling and all that...).

My Question is:
Does a multiple data arrays is allocated when marshaling the data from the
COM component to my C# component. I mean; Does an array is allocated in the
COM side and another array in the C# side and the content is copied among
this two arrays?
Or the C# side uses the allocated array directly at the COM side?


The SafeArray in 'COM land' is copied to a managed array in 'managed land'. Managed code
doesn't know anything about "SafeArrays" and COM doesn't know about "CLR arrays", so, one
needs to marshal the array from one representation to another, the COM (and the PInvoke)
interop marshaler knows exactly how to deal with this, as both array types carry the
necessary type information.

Willy.
 
Back
Top