Groups | Blog | Home
all groups > dotnet component services > july 2005 >

dotnet component services : JITA And Object Pooling


Ram
7/27/2005 5:33:30 AM
Hey,
I have a ServicedComponent that is configured to support Object Pooling
and Just In Time Activation.
I have the following code that uses my ServicedComponent:

Public Sub Test()
dim objSC as MyServicedComponent
objSC = New MyServicedComponent
objSC.Method()
End Sub

Oridnary I would call DisposeObject to release the object, but since
this object is JITA, should I call DisposeObject or not?
Thanks ahead

--Ram
Tomas Restrepo (MVP)
7/27/2005 5:48:25 PM
Ram,

[quoted text, click to view]

No, you shouldn't. In fact, if the object has deactivated itself (through
any of the possible ways it can do this) and you call Dispose(), you'll
force a new activation which will just attend the Dispose() call!

(yes, I find this totally unintuitive as well!)

--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/

Ram
7/27/2005 11:58:51 PM
Tomas hey thanks for replying,
The thing is, I defined my ServicedComponent as
JustInTimeActivation(true)
and at every method I need, I defiend:
ContextUtil.DeactivateOnReturn=true
And defined the min pool size to 5 and max to 10.
And all is well - when I look at the component services manager (MMC) I
see that after each call the number of objects activated returns to 0
all the time, but the number of object just keeps on increasing.
Doesnt the JITA returns my objects to the pool after each deactivation?
Thanks again

--Ram
Tomas Restrepo (MVP)
7/28/2005 8:35:19 PM
Ram,

[quoted text, click to view]

Yes, it does. If it didn't, you'd deadlock when the pool reached the maximum
size.

What you see is that the "Objects" statistic in the component services
manager doesn't actually mean number of objects, but rather the existing
number of connections; that is, the number of client side stubs connected to
the application, whether they are attached to an active object or not. What
you see is that you're probably ending up creating stubs even if they are
not needed, and those will drop after a gc (that happens because you're not
reusing the client side references to the objects bur rather discarding
them).

--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/

Ram
7/30/2005 3:29:52 PM
Does the number of connections affects the performance of my serviced
component?
If not, does is affect it at all?
And about not reusing the client side references to the object - I have
an ASP.Net web app that uses my JITA enabled serviced component on each
postback to the server.
How can I reuse the connection? hold a static instance to the object?
or am I missing the point?
Thanks again for your help!

Ram
Tomas Restrepo (MVP)
7/31/2005 9:27:14 AM
Ram,
[quoted text, click to view]
It shouldn't (at least not too bad, those will be taken care of by the GC).

[quoted text, click to view]

You reuse the connection by using the same client side proxy reference you
had to do another call after the object has been deactivated; when you do
that, COM+ automatically activates another object and attaches it to the
connection you had, transparent to the caller.

That said, you can't use a single one in a static variable for all your
calls...


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/

Ram
8/16/2005 11:05:07 AM
Tomas I'm sorry for the big delay, but I just want to tell you a HUGE
thanks!
You'v made clear what a few books and more than a couple of MS support
guys couldnt explain...
So again, thanks for "helping the community at times of need" ;)

Yours
Ram
Tomas Restrepo (MVP)
8/16/2005 6:43:10 PM
Ram,

[quoted text, click to view]

Hey, I'm happy to help :)


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/

AddThis Social Bookmark Button