axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nidhin Lazar (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AXIS2-5874) Memory leak when trying to getInputStream() from an External Repository data through AXIS
Date Mon, 11 Sep 2017 15:41:00 GMT

    [ https://issues.apache.org/jira/browse/AXIS2-5874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16161458#comment-16161458
] 

Nidhin Lazar commented on AXIS2-5874:
-------------------------------------

Thanks For the update Andreas Veithen

I have seen a similar issue raised AXIS2-5301, and seems like the call stack of out of memmory
error also similar.I can see you have worked on this issue as well.It would be a great help
if you could confirm if a fix has provided for this issue "AXIS2-5301", if there is a fix
then please share us the version details in which the fix went in.
https://issues.apache.org/jira/browse/AXIS2-5301

Also, I have a followup question on your previous update, as per you "The contract of DataHandler
allows multiple calls to getInputStream(). That means that requesting the stream and closing
it will not free the memory held by the DataHandler." ,So what would be the ideal way to access
data from datahandler without leaking memmory.Actually the API which we are using to download
content from the repository is returning us a DataHandler object, so we are forced to use
the DataHandler and we can see the memory is not been cleaned up even if we try to close the
inputstream.We have also tried anotehr method "WriteTo" which datahandler provides, and wrote
content to file and then closed the file, but this also not helping we can still see the memmory
leak.

following is the method we tried to access data from DataHandler object (which is returned
by the webservice API)

1) 	URL url = new URL("http://"host"/ws/CntSrvc.svc?wsdl");
	CntSrvc_Svc cService = new CntSrvc_Svc(url);
	CntSrvc cntSrvcClient = cService.getBasicHttpBindingCntSrvc(new MTOMFeature());
	InputStream in = null ;
	in = cntSrvcClient.download(contextIDString).getInputStream();
	// write in to a file.
	
	FileOutputStream fos = new FileOutputStream("c:/tmp/donwload.raw");
			
			byte[] buffer = new byte[8 * 1024];
		    int bytesRead;
		    while ((bytesRead = in.read(buffer)) != -1) {
		    	fos.write(buffer, 0, bytesRead);
		    }
		   
			if (fos != null) {
				fos.flush();
				fos.close();				
			}
			
	//closing the input stream
	if (in != null)
		{
			in.close(); 
		}

2) URL url = new URL("http://"host"/ws/CntSrvc.svc?wsdl");
	CntSrvc_Svc cService = new CntSrvc_Svc(url);
	CntSrvc cntSrvcClient = cService.getBasicHttpBindingCntSrvc(new MTOMFeature());
	DataHandler dh  = cntSrvcClient.download(contextIDString).
	File file = new File("c:/temp/newfile."+contextIDString);			
	OutputStream os = new FileOutputStream(file);
	dh.writeTo(os);
	os.flush();
	os.close();


In above both cases we are getting the out of memmory exception.We have written a sample java
application where we donot have AXIS2, and tried to download, then we are not seeing any memmory
leak.So as per our experiment when we use DataHandler in AXIS2 envionment we are getting this
out of memmory exception.
	
We are stuck on this issue from past 3 weeks , it would be a great help if you can shed some
light on this.
	
Regards,
Nidhin Lazar

> Memory leak when trying to getInputStream() from an External Repository data through
AXIS
> -----------------------------------------------------------------------------------------
>
>                 Key: AXIS2-5874
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5874
>             Project: Axis2
>          Issue Type: Bug
>          Components: jaxws, wsdl
>    Affects Versions: 1.6.2
>         Environment: Windows 2008
>            Reporter: Nidhin Lazar
>            Priority: Blocker
>
> We are using AXIS WS to connect and download files from an external repository .We are
using SOAP based webservice calls download an object. The API returns a DataHandler object,
from where we are getting the input stream. We have tried closing the inputstream object but
even after the close call we can see that the memory is still holding the stream, and eventually
the client machine is running out of memory.Any help on this would be highly appreciated.
> Our client code is as shown below
> URL url = new URL("http://"+host+"/ws/CntSrvc.svc?wsdl");
> CntSrvc_Svc cService = new CntSrvc_Svc(url);
> CntSrvc cntSrvcClient = cService.getBasicHttpBindingCntSrvc(new MTOMFeature());
> InputStream in = null ;
> in = cntSrvcClient.download(contextIDString).getInputStream();
> // write in to a file.
> //closing the input stream
> if (in != null){
>  in.close(); 
> }
> [Note;] Our client code runs under tomcat container, and this acts as a server to other
services.
> [Note:]We have created a sample client without using AXIS, where our client connecting
to external repository and download content.Here we donot see any memory leak.Our investigation
proves that its when we use AXIS and getinputstream() the memory is leaking, input stream
is not closing.Our current framework demands AXIS hence we would like to get a solution or
workaround for this issue



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message