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).
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.
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();
Eventually the service method finishes but it looks like the factory holds reference to the client proxy and therefore never GCs it.
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: http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?
Should I be doing this differently?
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.