Re: memory increase in calling between managed/unmanged code
- From: "David Browne" <davidbaxterbrowne no potted meat@xxxxxxxxxxx>
- Date: Sun, 3 Jul 2005 08:43:05 -0500
"vinu" <vinu_gt@xxxxxxxxx> wrote in message
news:eRuhWhvfFHA.2484@xxxxxxxxxxxxxxxxxxxxxxx
> Hi All,
>
> I have a very peculiar problem using .NET framework.
>
> I have a COM client(a dll that exposes COM interfaces for GUI
> applications)
> written in C++ which
> connects to a server(.exe written in C/C++) through SSL and SOAP.
>
> We use netscape SSL libraries and SOAP requests are created by us as
> strings
> and sent across to the
> server.
>
> 1) I have written a VB6( not .NET) application which calls the COM client
> which then connects to the server
> through SSL and executes SOAP rquests.
>
> 2) I also have a .NET wrapper(.dll) written in C# which exposes the COM
> client i mentioned above to managed applications.
> Now if i write a program(.net C# .exe or VB.Net .exe also) which use this
> .NET wrapper to call the COM client(which inturn calls the server)
> there is a sudden increase in memory and if we send requests in a loop,
> memory keeps on increasing.(This can be seen from the task manager).
> And all this memory increase happens in the server(.exe) process.
>
> But if i use the COM client directly as in 1) then there is no memory
> increase in the server.
>
> I find this strange as the server and my .NET program are running in two
> different process spaces and we are
> connecting through socket(SSL or plain).
>
> My guess is this is happening because of some marshalling between managed
> world and unmanged world.
>
In unmanaged COM when you un-reference a COM object its reference count is
decremented, and when its reference count goes to zero it's memory is
released.
In managed code COM interop each COM object is held in a managed wrapper,
called a Runtime Callable Wrapper. Only when the RCW is finalized will the
referenced COM object be freed.
You can call Marshal.ReleaseComObject() against the RCW to immediately
decrement the reference count.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeinteropservicesmarshalclassreleasecomobjecttopic.asp
David
.
- References:
- Prev by Date: memory increase in calling between managed/unmanged code
- Next by Date: Re: Serious regression: Win2K3 SP1 kills Timers
- Previous by thread: memory increase in calling between managed/unmanged code
- Next by thread: Re: Serious regression: Win2K3 SP1 kills Timers
- Index(es):
Relevant Pages
|