hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Glück <ortwin.glu...@nose.ch>
Subject Re: out out memory problem of Httpclient
Date Thu, 03 Feb 2005 09:13:05 GMT
Antonio,

This is not a problem with HttpClient but with the way you deal with the 
content. You are buffering the complete response in memory. Moreover the 
way you create the String, copying occurs, so in fact the data is stored 
twice in memory. I don't know what data you are dealing with. You should 
find a way to keep as little data in memory at a time. If the data is 
XML, you could feed the stream into a SAX parser for instance.

Ortwin Glück

Antonio Xu wrote:
>           InputStream is = method.getResponseBodyAsStream();  // if the 
> download file more than 2MB, before the stream will be returned, the 
> httpclient throw a out of memory exception.
>           is.read(buf, 0, 20480-1);
>           res = new String(buf);
>           is.close();

-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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


Mime
View raw message