COM+ pool object in C# is not return to the pool

G

Guest

Hi All:

I am creating a COM+ Pool object in C#. I set up the following attributes:
JIT (true),Pool size; and at the end of each public method I called
ContextUtil.DeactivateOnReturn=true to set DONE flag; and also I override
CanBeBooled method to true.

In my calling program in C#, first of all I am using NEW to create a object,
then I call the method then I call dispose.

No matter how I try I do not see the object has been released back to pool.
Does anyone have similar problem ?

Thanks in advance
 
N

Nicholas Paldino [.NET/C# MVP]

You should attach the AutoComplete attribute to every method that you
expose. This is needed to release the object back to the pool.

Also, don't call Dispose on your object. This has the effect of pulling
an object from the pool, activating it, and then releasing it back to the
pool. It's a wasted call.

If you use the AutoComplete attribute, you don't need to set the
DeactivateOnReturn property.

If you want to have dispose semantics on a JIT activated object, then
you need to override the Activate and Deactivate methods on your component
based on ServicedComponent.

Additionally, if the component is not JIT activated, then you would need
to call Dispose to release it back to the pool. When it is JIT activated,
then the object is pulled from the pool and activated before every call.

Hope this helps.
 
G

Guest

I tried AutoComplete attribute and comment out DeactivateOnReturn code in my
public method.

In additon, since COM+ pool object is JIT. I override Activate and Deactive
method with code like base.Activate and base.Deactive.

Here is calling routine:
.....
using (CommandCenter myPool = new CommandCenter())
{
sRet = myPool.GetSybaseODBCConnection
("insightdb","nyns0608");
}
.....
and I still do not see object is return to the pool.


Nicholas Paldino said:
You should attach the AutoComplete attribute to every method that you
expose. This is needed to release the object back to the pool.

Also, don't call Dispose on your object. This has the effect of pulling
an object from the pool, activating it, and then releasing it back to the
pool. It's a wasted call.

If you use the AutoComplete attribute, you don't need to set the
DeactivateOnReturn property.

If you want to have dispose semantics on a JIT activated object, then
you need to override the Activate and Deactivate methods on your component
based on ServicedComponent.

Additionally, if the component is not JIT activated, then you would need
to call Dispose to release it back to the pool. When it is JIT activated,
then the object is pulled from the pool and activated before every call.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi All:

I am creating a COM+ Pool object in C#. I set up the following attributes:
JIT (true),Pool size; and at the end of each public method I called
ContextUtil.DeactivateOnReturn=true to set DONE flag; and also I override
CanBeBooled method to true.

In my calling program in C#, first of all I am using NEW to create a
object,
then I call the method then I call dispose.

No matter how I try I do not see the object has been released back to
pool.
Does anyone have similar problem ?

Thanks in advance
 
N

Nicholas Paldino [.NET/C# MVP]

How are you making the determination that the object is getting returned
to the pool?

Also, is CommandCenter your serviced component? If so, you should NOT
be using it in a using statement, and you should NOT call dispose on it
(since it is JIT activated and pooled).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I tried AutoComplete attribute and comment out DeactivateOnReturn code in
my
public method.

In additon, since COM+ pool object is JIT. I override Activate and
Deactive
method with code like base.Activate and base.Deactive.

Here is calling routine:
....
using (CommandCenter myPool = new CommandCenter())
{
sRet = myPool.GetSybaseODBCConnection
("insightdb","nyns0608");
}
....
and I still do not see object is return to the pool.


Nicholas Paldino said:
You should attach the AutoComplete attribute to every method that you
expose. This is needed to release the object back to the pool.

Also, don't call Dispose on your object. This has the effect of
pulling
an object from the pool, activating it, and then releasing it back to the
pool. It's a wasted call.

If you use the AutoComplete attribute, you don't need to set the
DeactivateOnReturn property.

If you want to have dispose semantics on a JIT activated object, then
you need to override the Activate and Deactivate methods on your
component
based on ServicedComponent.

Additionally, if the component is not JIT activated, then you would
need
to call Dispose to release it back to the pool. When it is JIT
activated,
then the object is pulled from the pool and activated before every call.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi All:

I am creating a COM+ Pool object in C#. I set up the following
attributes:
JIT (true),Pool size; and at the end of each public method I called
ContextUtil.DeactivateOnReturn=true to set DONE flag; and also I
override
CanBeBooled method to true.

In my calling program in C#, first of all I am using NEW to create a
object,
then I call the method then I call dispose.

No matter how I try I do not see the object has been released back to
pool.
Does anyone have similar problem ?

Thanks in advance
 
G

Guest

two ways: one way is looking at memory useage DllHost is keeping getting
bigger after each client call. The other way is looking at status view on
COM+ managers. There is nothing under Pooled column.

Yes, my commandcenter is serviced component. I was reading somewhere
recommended to use Dispose no matter what.

Nicholas Paldino said:
How are you making the determination that the object is getting returned
to the pool?

Also, is CommandCenter your serviced component? If so, you should NOT
be using it in a using statement, and you should NOT call dispose on it
(since it is JIT activated and pooled).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I tried AutoComplete attribute and comment out DeactivateOnReturn code in
my
public method.

In additon, since COM+ pool object is JIT. I override Activate and
Deactive
method with code like base.Activate and base.Deactive.

Here is calling routine:
....
using (CommandCenter myPool = new CommandCenter())
{
sRet = myPool.GetSybaseODBCConnection
("insightdb","nyns0608");
}
....
and I still do not see object is return to the pool.


Nicholas Paldino said:
You should attach the AutoComplete attribute to every method that you
expose. This is needed to release the object back to the pool.

Also, don't call Dispose on your object. This has the effect of
pulling
an object from the pool, activating it, and then releasing it back to the
pool. It's a wasted call.

If you use the AutoComplete attribute, you don't need to set the
DeactivateOnReturn property.

If you want to have dispose semantics on a JIT activated object, then
you need to override the Activate and Deactivate methods on your
component
based on ServicedComponent.

Additionally, if the component is not JIT activated, then you would
need
to call Dispose to release it back to the pool. When it is JIT
activated,
then the object is pulled from the pool and activated before every call.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

message Hi All:

I am creating a COM+ Pool object in C#. I set up the following
attributes:
JIT (true),Pool size; and at the end of each public method I called
ContextUtil.DeactivateOnReturn=true to set DONE flag; and also I
override
CanBeBooled method to true.

In my calling program in C#, first of all I am using NEW to create a
object,
then I call the method then I call dispose.

No matter how I try I do not see the object has been released back to
pool.
Does anyone have similar problem ?

Thanks in advance
 
N

Nicholas Paldino [.NET/C# MVP]

In this case, no, you can not call Dispose. If you do, you are pulling
a new object from the pool, and then it is being activated (because of JIT),
and then you are calling Dispose, and deactivating the object. It's a waste
of a call.

You aren't saving state across calls to this object, are you? It is
EXTREMELY important that you do not persist state in your objects when you
pool them like this (at least, state that is modified as the result of
calls, state that is created at object construction time which is the same
across all pooled instances is ok).

Also, looking at the memory usage for DllHost isn't going to tell you
anything, since that is just .NET doing what .NET does (to put it simply)
when it comes to memory management and the like. Also, how can you be sure
which DllHost process is yours?

In the Pooled column in the status view, it tells you how many objects
are currently in the pool. It doesn't tell you if objects are not released.

I think your objects really are being pooled correctly, you just think
they arent.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


two ways: one way is looking at memory useage DllHost is keeping getting
bigger after each client call. The other way is looking at status view on
COM+ managers. There is nothing under Pooled column.

Yes, my commandcenter is serviced component. I was reading somewhere
recommended to use Dispose no matter what.

Nicholas Paldino said:
How are you making the determination that the object is getting
returned
to the pool?

Also, is CommandCenter your serviced component? If so, you should
NOT
be using it in a using statement, and you should NOT call dispose on it
(since it is JIT activated and pooled).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I tried AutoComplete attribute and comment out DeactivateOnReturn code
in
my
public method.

In additon, since COM+ pool object is JIT. I override Activate and
Deactive
method with code like base.Activate and base.Deactive.

Here is calling routine:
....
using (CommandCenter myPool = new CommandCenter())
{
sRet = myPool.GetSybaseODBCConnection
("insightdb","nyns0608");
}
....
and I still do not see object is return to the pool.


:

You should attach the AutoComplete attribute to every method that
you
expose. This is needed to release the object back to the pool.

Also, don't call Dispose on your object. This has the effect of
pulling
an object from the pool, activating it, and then releasing it back to
the
pool. It's a wasted call.

If you use the AutoComplete attribute, you don't need to set the
DeactivateOnReturn property.

If you want to have dispose semantics on a JIT activated object,
then
you need to override the Activate and Deactivate methods on your
component
based on ServicedComponent.

Additionally, if the component is not JIT activated, then you
would
need
to call Dispose to release it back to the pool. When it is JIT
activated,
then the object is pulled from the pool and activated before every
call.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

in
message Hi All:

I am creating a COM+ Pool object in C#. I set up the following
attributes:
JIT (true),Pool size; and at the end of each public method I called
ContextUtil.DeactivateOnReturn=true to set DONE flag; and also I
override
CanBeBooled method to true.

In my calling program in C#, first of all I am using NEW to create a
object,
then I call the method then I call dispose.

No matter how I try I do not see the object has been released back
to
pool.
Does anyone have similar problem ?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top