Hi,

We have been using the CXF 2.1.5 library as WS client from quite some time.
Recently we started observing a memory leak happening on the client side and
on further investigation it zeroed down to few cxf classes. (refer
CXF-InstanceSizes.JPG)

While we were working on digging into the leak we also thought of upgrading
to newer version as we were on an older one.
Hence, we upgraded the client to CXF 2.4 without making any changes to our
code, and memory profilers showed a stable memory graph. (refer
CXFSize-2.4.0.JPG)

Then in a separate attempt, we changed the way we were creating the
client (snippets below) keeping the client version as CXF 2.1.5 and that
also solved the memory leak problem for us.
I would like to ask the group, based on the changes we did in our code,
that

   - Was there any leak associated to creation of "*JaxWsProxyFactoryBean*"
   in 2.1.5 that was fixed in later releases, as without any changes our code
   works well in later releases.
   - Are the changes that we are doing correctly initializing and using CXF
   or is there any other ideal way to use it.


*Ealier Client Code** (Leaks in 2.1.5 but not in later versions)*
                JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ServiceClient.class);
factory.setAddress(webServiceAddress);

ServiceClient serviceClient = null;
try {
serviceClient = (ServiceClient ) factory.create();
Client client = ClientProxy.getClient(serviceClient );
if (client != null){
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
..
                        policy.setConnectionTimeout(connectionTimeOut);
policy.setReceiveTimeout(connectionTimeOut);
conduit.setClient(policy);
}

} catch (Exception ex) {

} catch (Error er) {

}

***Above code is called for every request that is made from the client.*

In the changed code we are calling the above snippet only once to create the
'*ServiceClient*' and then reusing the serviceClient in subsequent calls.
Please let me know if any further details are required to answer my queries.

Thanks in advance.

-- 
Carpe Diem!
Gautam Saggar

Reply via email to