Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.4.1
-
None
-
None
-
Axis2 1.4.1
jdk1.5.0_12
Description
For Axis2 1.4.1, if I instantiate a new client stub for every web service request, the stub is not freed. This was not happened with Axis2 1.2. For example, I modified Version service's getVersion() to do following:
public sample.axisversion.GetVersionResponse getVersion() throws ExceptionException0 {
TestServiceStub stub = null;
try
catch (AxisFault e)
{ System.err.println(e.getMessage()); } catch (RemoteException e) { System.err.println(e.getMessage()); } finally {
if (stub != null) {
try
catch (AxisFault e)
{ System.err.println(e.getMessage()); } }
}
GetVersionResponse response = new GetVersionResponse();
response.set_return("1.4.1");
return response;
}
Each time getVersion() is called, it creates a new instance of TestServiceStub, and uses it to send out a HelloRequest. I put this modified Version.aar along with the TestService.aar into axis2_141.war and deployed it to JBoss. After I sent multiple version requests to the Version service, I saw significant memory leak for JBOSS.
I also tried to keep an instance of the stub into a singleton class, and use the same instance every time as following:
public sample.axisversion.GetVersionResponse getVersion() throws ExceptionException0 {
TestServiceStub stub = null;
try
catch (AxisFault e)
{ System.err.println(e.getMessage()); } catch (RemoteException e) { System.err.println(e.getMessage()); } GetVersionResponse response = new GetVersionResponse();
response.set_return("1.4.1");
return response;
}
This workaround fixed the memory leak. But in our applications, we have situations that new client stub has to be created each time. I think the better solution is for Axis2 to free the client stub.
Attachments
Issue Links
- relates to
-
AXIS2-4163 ServiceClient - finalize() method calls super.finalize() too early
-
- Resolved
-