I'm developing an application using Axis2 1.4 which consists of a
client and service. Stubs are generated using the wsdl2java tool using
ADB.

I am seeing what appears to be a huge resource leak when using the
client code from the service. After processing a couple dozen service
requests (each service requests runs a few client requests), the heap
quickly fills up and the JVM runs out of memory.

Analysing the heap shows hundreds of thousands of
ConcurrentHashMap$Segment, ConcurrentHashMap$HashEntry[] and
ReentrantLock$NonfairSync objects, and tens of thousands of HashMap,
HashMap$Entry[], String, Object[], ArrayList,
org.apache.axis2.description.ParameterIncludeImpl,
org.apache.axis2.description.PolicySubject for example.

Executing the service without making any client calls works just fine.

Executing the client by itself in a standalone app works just fine.

After pulling my hair out for the past 24 hours trying to figure out
the root cause and desperately googling for answers, I finally found
that calling MyStub._getService().cleanup() appears to fix the leak
(at least the service can process requests for over an hour where it
would die within minutes).

So, my questions are:

Is it normal to have to call ServiceClient.cleanup()?
Why do I have to explicitly call it when using the client code from my
service and not have to call it when running the client code as a
standalone application?
Should I be reusing stubs if possible?

Code looks like this:

public class MyService implements MyServiceSkeletonInterface {
 public MyProcessResponse myProcess() {
  MyProcessResponse res = new MyProcessResponse();
  WebServiceUtil.clientCall1();
  WebServiceUtil.clientCall2();
  res.setProcessResponseResult("OK");
  return res;
 }
}

public class WebServiceUtil {
 public static void clientCall1() {
  MyServiceStub stub = new MyServiceStub("http://example.com/myservice";);
  ClientCall1 req = new ClientCall1();
  ClientCall1Response res = stub.clientCall1(req);
  // Need to call this when calling using this function in a web service
  // Otherwise huge resource leak occurs
  stub._getServiceClient().cleanup();
 }
}

Any thoughts appreciated.

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to