Re: memory increase in calling between managed/unmanged code

Tech-Archive recommends: Fix windows errors by optimizing your registry




"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


.



Relevant Pages

  • Re: 4-way Opteron vs. Xeon-IBM X3 architecture
    ... >>>The point here is that the issue concerns both speed AND capacity. ... >As to the reference, the message header points right back in this thread, ... >>>As you may suspect, I read plenty about memory systems, and I would ... >>>from the enthusiast market and assumed that it would work in the server ...
    (comp.sys.ibm.pc.hardware.chips)
  • Re: 4-way Opteron vs. Xeon-IBM X3 architecture
    ... I did not see any concrete reference other than to THG. ... >reliably add more memory to the Opteron system @ 400 Mb/s. ... >> With the right devices and with registering the server market should be ... >following the new spec. ...
    (comp.sys.ibm.pc.hardware.chips)
  • Re: Memory issues with 64-bit SQL Server 2005 on 64-bit Win 2003 C
    ... Manager nusance has been around, and yet they somehow could never find time ... counter Total Server Mmeory shows 18GB. ... due to how the large memory allocation APIs work. ... Swap files for SQL do not need to be more than about 2-4 GB ...
    (microsoft.public.sqlserver.clustering)
  • Re: Open Outlook on user machine
    ... AppDomain within the hosted CLR ends, and thus the need to do any releasing ... The COM object is instantiated and is in memory on the unmanaged ... process (use the Task Manager to verify that the COM object's process is ... thus reducing its reference count to zero. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: memory
    ... One way to find out if SQL Server is bottlenecked on RAM is to check these ... Memory and SQLServer:Memory Manager: Target Server Memory. ... SQLServer:Memory Manager: Target Server Memory counters is larger than ...
    (microsoft.public.sqlserver.server)