hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suladna <sula...@yahoo.com>
Subject My HttpClient gives me a memory leak
Date Thu, 04 Sep 2008 07:40:46 GMT
I have used the following tutorial to bring html-code from websites to my java program:
The websites which I connect to all start with www.xxxxxxxxx.se *  but they have different
So I start by making one HttpHost and defining a HttpEntity and HttpRespons
final HttpHost target = new HttpHost("www.xxxxxxx.se", 80, "http");
HttpEntity entity = null;
HttpResponse rsp = null;

After that I use a loop to connect to each subsite. This is what I write in the loop:
HttpRequest req = createRequest(urlEnding);
rsp = client.execute(target, req);
entity = rsp.getEntity();
String[] line = EntityUtils.toString(entity).split("\n"); //this info is used by the program
if (entity != null){
It basically works fine, but the problem is that I get a memory leak.. after having brought
the code from a few hundred websites I get a java.lang.OutOfMemoryError: Java heap space.
Is there anything I can do in the loop except entity.consumeConent() to prevent this from
I attach my java code as a text file. It is just a slight modification of the code in the
* this is not the real domain.. if anyone wants to know the real domain, please send me a
private e-mail

View raw message