Memory consumption when using COM interop?

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?
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top