hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalnichevski, Oleg" <oleg.kalnichev...@bearingpoint.com>
Subject RE: Memory Leaks when web server hangs
Date Mon, 02 Feb 2004 10:20:47 GMT
> Mike and Oleg, the stack trace Srini included indicates that HttpClient is
> attempting to create a new timeout thread on every connection - does this
> always occur or is it just one timeout thread per httpclient instance?  It
> would be ideal if we could reduce this to one static thread as starting
> threads is never nice for server side apps.  Not sure how feasible that is
> though.

Hi Srini,
HttpClient uses an additional controller thread to work around the limitation of older (<
1.4) JDKs which do not provide a possibility to set connect timeout. If you do not really
need to control connect timeout (for instance, when communicating with an intranet site with
good availability) simply set connect timeout to. That will prevent HttpClient from spawning
an additional thread per request.

Adrian, et al
Another possibility to use reflection to set connect timeout using the Socket methods when
running in JVM 1.4 or above

Oleg



-----Original Message-----
From: Adrian Sutton [mailto:adrian@intencha.com]
Sent: Monday, February 02, 2004 09:03
To: Commons HttpClient Project
Subject: Re: Memory Leaks when web server hangs


On 2/2/04 2:00 PM, "Srinivas Vemula" <srinivas.vemula@mensamind.com> wrote:

> Hi All,
>       We are seeing thread leaks when having client open connections to a web
> server that hangs. Has any one seen this happening?? How do we ensure that the
> library correctly closes  socket connections on failures, cleaning up system
> resources, and  threads actually finish in  the timeout period and get freed
> up. Would using MultiThreadedHttpConnectionManager
> <file:///D:/silkroad/http-commons/commons-httpclient-2.0-rc3/docs/threading.ht
> ml#MultiThreadedHttpConnectionManager>   be of any help??

Hi Srini,
If you're using the same HttpClient instance across multiple threads, you
must use the MultiThreadedHttpConnectionManager or you'll run into strange
problems.  If you're using separate HttpClient instances, you may as well
stick with the single threaded (default) connection manager.

In terms of connections hanging - you probably want to look into the
setConnectionTimeout and setTimeout methods of the HttpClient class.  These
allow you to control how long HttpClient waits when making a connection and
how long it waits for data once the connection is established.  If you have
set either of these to 0 (not sure what the default is, it may be platform
specific) the connection will never timeout which sounds a lot like what
you're seeing.

Mike and Oleg, the stack trace Srini included indicates that HttpClient is
attempting to create a new timeout thread on every connection - does this
always occur or is it just one timeout thread per httpclient instance?  It
would be ideal if we could reduce this to one static thread as starting
threads is never nice for server side apps.  Not sure how feasible that is
though.

> Srini

Regards,

Adrian Sutton.

----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 38478913 0422236329
Suite 8/29 Oatland Crescent
Holland Park West 4121
Australia QLD
www.intencha.com


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


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


Mime
View raw message