Re: COM+ object not being released back to the pool




"VinDotNet" <avlokana@xxxxxxxxx> wrote in message
news:1120220920.560358.226510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Nick, thanks for taking time to think over my query.
> Yup I read the same about AutoComplete and put it over the methods in
> the servicedcomponent derived class. But you know what I also read
> somewhere else that If your class inherits from an interface and you
> are exposing the interface methods, then its not gonna work. I am
> implementing an interface in my servcomp derived class and these
> methods are to be called by the com clients.
>
> Yup I know the database connection has to be in activate() I've done
> that change and its fine. But my basic problem (releasing to the pool)
> is still there.
>
> Now in my mc++ winform client, I am doing an activator.createinstance()
> Then typecasting the object to the interface, then access methods on
> them.
> There is no other way I can create the com component, coz this part of
> the code is out of my scope. I am not supposed to touch it.
>
> Can I get some more ideas/resolutions from you?
>
> Willy, as I said above, at the client, I do a
> obj = (Imycominterface) activator.createinstance();
> obj.Myservermethod();
> Yup I am overriding CanBePooled() and returning true.
>
> Thanks in advance,
> Vin
>

As long as your client holds a reference to the object, the object will stay
activated. Now when the object reference gets released, that is when the
reference goes out of scope or is explicitly set to null, the object is kept
alive by it's proxy/stub pair and the COM+ object lifetime is determined by
the GC.
If you want the object to get released to the pool deterministically, you
have to call DisposeObject before you release the object reference, failing
to do this puts you at the mercy of the GC to return your objects to the
pool.
When this is done the object gets back to the pool, or is immediately
re-used by another client who had a request pending when the pool was
exhausted (max. objects reached).

So basically your client should look like this....
{
Imycominterface obj =
Activator.CreateInstance(typeof(SomeCOMPPClass)) as Imycominterface;
...
use the object
System.EnterpriseServices.ServicedComponent.DisposeObject(objas
SomeCOMPPClass)
}

CreateInstance will pull an object from the pool or create (construct) a new
one.
DisposeObject will release the proxy/stub and the COM+ infrastructure will
all or not put it back in the pool depending on the return value from
CanBePooled.
Note that when an object is picked-up from the pool that your Activate()
method is called and when it's put back in the pool that Deactivate is
called followed by a call to CanBePooled. Did you ever traced these calls?

Willy.





.



Relevant Pages

  • Re: Limit number of COM+ sessions
    ... I changed the Max Pool size to 1 through the Component Services ... own (the client) process. ... You configure your component to run as Server or as Library by applying the ... Only Server types can be pooled, object pooling can be configured by ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread info
    ... > client, now when I close the applet and open another one it creates the ... is common practice for a server to have a thread pool. ... a thread is selected from the pool to service that client. ... Is there a reason you need a continuous connection and that a request-based ...
    (comp.lang.java.programmer)
  • Re: I cant create thread more than 256 on Redhat 9
    ... So you don't need one thread for each client, ... aren't any practical 'process pool' servers that use a pool of processes the ... same way a thread pool server uses a pool of threads. ... of sharing file descriptors but it's also the difficulty of managing client ...
    (comp.os.linux.development.apps)
  • Re: Application Flow / security issues
    ... impersonation and makes it possible for the server process to access remote ... resources while acting as the client." ... because i assume the root of this problem is the application pool. ... You can set impersonation in the web.config. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: NTPD on Windows NT4
    ... >> Heiko Gerstung wrote: ... >> Listening on interface Loopback Interface 1, ... >> addresses from the europe ntp pool which your installation procedure ... > pool servers, but a lot of these countries only have very few pool ...
    (comp.protocols.time.ntp)