On Wed, Jul 30, 2008 at 6:21 AM, David Rees <[EMAIL PROTECTED]> wrote:

> 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();


this method should be call when the MyServiceStub (see finalize method in
ServiceClient) is garbage collected. I am not sure why it is not being
called automatically.

In RC1 we fixed a memory leak regarding this. But I can not realy think the
reason for your problem.
you can get the AxisConfiguration object like this,
AxisConfiguration axiConfiguration =
MessageContext.getCurrentMessageContext().getConfigurationContext().getAxisConfiguration();

and check whether there are some additional objects there after calling
clean up.

Please log a jira.

thanks,
Amila.



>  }
> }
>
> Any thoughts appreciated.
>
> -Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Amila Suriarachchi,
WSO2 Inc.

Reply via email to