release com+ objects in Windows 2003 server

  • Thread starter Thread starter Praveen
  • Start date Start date
P

Praveen

Hi
I have developed some com+ component in dotnet using below
System.Runtime.InteropServices
System.EnterpriseServices

I am creating object of these components in asp pages and invoking from
other com dlls ( developed in VC++) . I observe a strange behavior in
windows 2003 server. After
the function call the object is not released. Every call keeps adding to the
number of activated objects and finally it reaches the limit of my pooling
setup and fails.
I am setting the object to nothing in the asp which should ideally update
the ref count of the com object and release it.

This worked perfectly in Windows 2k and XP.

I know a workaround for this. If i call the dispose function it releases the
object. I was reluctant to change the code base on the Operating System.

Please advice how to get this issue resolved.

Thanks in advance,
Praveen
 
I'm not sure why you are seeing this behavior on W2K3 only (probably
because it has a newer COM+ version), but calling Dispose in ALL OSes
is the right thing to do.

Dispose will ensure that all unmanaged resources will get rid of at the
time you call Dispose instead of when the object will actually get
garbage collected.

Hope this helps,
Eran.
=============================================================
http://dotnetdebug.blogspot.com - Advanced .NET Debugging blog
The place for Windbg, SOS, live and post mortem debugging tips, tricks
and other stuff.
 
Hi Eran.
As I mentioned earlier I have made a com+ dll in dotnet. To an application
( asp , vb prog, vc prog) its just another com dll. I did not want to call
any extra functions to release the dll.

Consider a case where these apps are written even before development of
dotnet and doing an invoke with progid and function name.

Thanks for your help.
Praveen
 
Hi

Due to managed code's feature, GC will do the job to collect the resource,
and it has its own algorithm to do the job.

Here is document for your reference.
Understanding Enterprise Services (COM+) in .NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/entserv.asp

A good design practice for using JIT is to:

Place custom activation and finalization code in the constructor and
Dispose(bool) methods, not to implement a finalizer and use a single call
pattern by indicating doneness using the AutoComplete attribute on the
method.
Call Dispose() from the client when the client is done with the object.
The discussion has assumed the client is managed and the component is
in-process. When the component is out-of-process: (More details are
outlined in the remoting section)

The GC will only clean up the objects when their .NET remoting lease time
has expired for client-activated objects.
As noted earlier, when calling methods on out-of-process components, DCOM
is used to switch the context and deliver the method call. If the component
has been deactivated by JIT earlier and then a call to Dispose() is made,
the server context will be entered and the real object will be re-created
to service the DCOM call and finally deactivated again. For in-process
components, if the real object has been deactivated, no attempt is made to
switch to the correct context before servicing the Dispose() call (which
would re-activate the component), instead, only the context is destroyed.


Per the document above, we recommended to call Dispose after done with the
object.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top