我已将 c# dll 公开为 .net 服务组件 (com+) 。它正在被无人管理的客户端(Unify Vision)使用。我已将该组件部署在组件服务下。
我将池大小设置为 5,创建时间设置为 2 分钟。我在服务器模式下运行 com+。并将空闲关机时间设置为3分钟。
一切工作正常,但一旦达到最大池大小(5),进程就会保持活动状态而不会被清理。因此,如果我尝试再创建一个对象,它就会失败并挂起。
消费者似乎没有释放对象。该服务组件公开了两个方法 _Destroy 和 Dispose。一旦使用了对象,我必须使用哪一个来释放该对象。另外,调用这些方法后对象是否会立即释放。有什么方法可以找出该对象有多少个引用吗?
另外,我是否需要使用 JIT 之类的东西并设置自动完成属性?不过我已经尝试过这个选项了。
我不确定该对象是否被释放回池中。如何追踪这个?
请帮忙
谢谢
斯韦拉普
I have exposed c# dll as .net serviced component (com+) . It is being consumed by an unmananged client (Unify Vision). I have deployed this component under component services.
I set the pool size to 5 and the creation time out to 2 minutes. I am running the com+ under server mode. and set the idle shutdown time to 3 minutes.
Everything is working fine but once the max pool size(5) is reached, the processes are staying alive without getting cleaned up. And due to this,if I try to creat one more object ,its failing and hanging.
It seems that objects are not getting released by the consumer. There are two methods _Destroy and Dispose exposed by this serviced component. Which one do I have to use for releasing the object once it is used. Also, will the object get released immediately after the call to these methods. Is there any way to find out how many references are there to the object?
Also, Do I need to use anything like JIT and setting the auto complete attribute?. I already tried this option though.
I am not sure whether the object is getting released back to the pool. How to track this?
Please help
Thanks
sveerap
发布评论
评论(1)
由于您正在处理服务器(进程外)应用程序,因此客户端不必调用 Dispose()。如果您的组件配置正确,那么 dispose 实际上会创建/激活一个新实例,只是为了调用 Dispose 方法。在文章 对象生命周期 ://msdn.microsoft.com/en-us/library/ms973847.aspx" rel="nofollow">了解 .NET 中的企业服务 (COM+) 了解完整情况。
是的,它将返回到池中。
使用 COM+ Explorer 查看应用程序中的所有组件。将视图设置为状态,您将看到对象数量、激活对象数量、池对象数量和调用时间。
是的,您必须使用 JIT 并调用 ContextUtil.DeactivateOnReturn = true;。
您可以重写 Activate 和 Deactivate 方法来查看组件何时从池中删除并释放回池。
下面是一个示例,该池的最大数量为 1 个对象,但在方法调用后立即将实例返回到池中:
如果您由多个客户端同时调用 Hello 方法而不释放客户端对象,您将看到该方法不会阻塞(调用期间除外)因为Hello方法返回后对象被释放回池中。使用 DebugView 查看调用顺序。这里有 2 个客户端同时调用,并在调用 Hello 后立即休眠。
Since you are dealing with a Server (out of process) Application the client should not have to call Dispose(). If your component is configured properly dispose will actually create/activate a new instance just to invoke the Dispose method. Read about Object Lifetimes in the article Understanding Enterprise Services (COM+) in .NET for a full picture.
Yes, it will be returned to the pool.
Use the COM+ Explorer to view all components in your application. Set the view to status and you will get to see the number of objects, the number of activated objects, the number of pooled objects, and the call time.
Yes, you will have to use JIT and call
ContextUtil.DeactivateOnReturn = true;
.You can override the Activate and Deactivate methods to see when your component is removed from the pool and released back to the pool.
Here's an example that has a pool with a maximum number of 1 object but returns the instance to pool immediately after the method call:
If you call the Hello method concurrently by multiple clients without releasing the client objects you will see that the method does not block (except for the duration of the call) because the object is released back to the pool after the Hello method returns. Use DebugView to see the sequence of calls. Here are 2 clients calling concurrently with a sleep immediately after the call to Hello.