我发现我的应用程序严重泄漏内存.进行堆转储后,似乎Apache CXF(2.7.7)似乎引用了许多JaxWsServiceConfiguration(一天14000).
I've discovered my application is heavily leaking memory. After taking heap dumps it appears Apache CXF (2.7.7) seems to be referencing lots of JaxWsServiceConfiguration (14000 in a day).
我不确定是否正确使用它,是否需要以某种方式释放客户端或CXF中是否有错误.希望有人可以在这里指出正确的方向.
I'm not sure if I am using it correctly, whether I need to somehow release the client or there is a bug in CXF. Hopefully somebody can point me in the right direction here.
我正在使用JaxWsProxyFactoryBean注入我的服务方法中.调用以下行来创建客户端代理(对Web服务的每个请求都需要调用):
I am using a JaxWsProxyFactoryBean injected into my service methods. The following line is called to create the client proxy (called for every request to the web service):
jaxWsProxyFactoryBean.create();服务方法最终完成了,但是看起来工厂持有对客户端代理的引用,因此从不对它进行GC.
Eventually the service method finishes but it looks like the factory holds reference to the client proxy and therefore never GCs it.
我以为我可以创建一个静态客户端并始终使用它,但是对此有些不安,因为它并非在所有情况下都是线程安全的: cxf.apache/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe ?
I thought I could create a single static client and always use this but am a little nervous of this since it is not thread-safe in all circumstances: cxf.apache/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?
我应该做些不同的事情吗?
Should I be doing this differently?
推荐答案在构建网关以代表数百个并发客户端使用Web服务时,我始终使用静态代理.只要不针对给定请求修改拦截器链,例如修改管道或使用会话,都应该没有问题.
I use static proxies all the time when I build gateways to consume a web service on behalf of hundreds of concurrent clients. It should be no problem whatsoever as long as the interceptor chain is not modified for a given request, for example modification to the conduit or use of sessions.
更多推荐
Apache CXF不释放客户端
发布评论