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

Oleg Kalnichevski edited comment on HTTPASYNC-116 at 1/27/17 10:04 AM:
-----------------------------------------------------------------------

Rob,
Many thanks for testing the patch. 

Immediate removal of LeaseRequest from the lease request queue would require 
acquisition of the pool lock and a linear scan of the request queue, which 
would be very expensive and cause extra contention for the pool lock. The best 
I can do here is to expose 
[validatePendingRequests|https://github.com/apache/httpcore/blob/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java#L480]
 method of the internal connection pool and let individual applications decide 
when and how often to purge the lease request queue.

Oleg



http://hc.apache.org/httpcomponents-asyncclient-4.1.x/httpasyncclient/apidocs/org/apache/http/nio/conn/NHttpClientConnectionManager.html#closeExpiredConnections()


was (Author: olegk):
Rob,
Many thanks for testing the patch. 

Immediate removal of LeaseRequest from the lease request queue would require 
acquisition of the pool lock and a linear scan of the request queue, which 
would be very expensive and cause extra contention for the pool lock. The best 
I can do here is to expose 
[blah|https://github.com/apache/httpcore/blob/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java#L480]
 



http://hc.apache.org/httpcomponents-asyncclient-4.1.x/httpasyncclient/apidocs/org/apache/http/nio/conn/NHttpClientConnectionManager.html#closeExpiredConnections()

> Cancelling the Future returned by CloseableHttpAsyncClient should release all 
> resources allocated to the request that created it.
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPASYNC-116
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-116
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Improvement
>    Affects Versions: 4.1.1
>            Reporter: Rob Griffin
>            Assignee: Oleg Kalnichevski
>             Fix For: 4.1.2
>
>         Attachments: ScreenShot001.jpg, ScreenShot026.jpg
>
>
> We call CloseableHttpAsyncClient.execute() to execute HTTP PUTs at the rate 
> of several hundred per minute. Sometimes our web site slows down and does not 
> respond quickly enough and when this occurs the requests back up. We have 
> code that detects this and cancels the Future returned from the execute 
> method when the request has waited too long. If this happens too often the 
> application crashes with an out of memory error. 
>  
> Analysis of a dump showed that there were more 108,000 instances of 
> org.apache.http.nio.pool.LeaseRequest along with a similar number of 
> instances of other HTTP Client classes. Inspecting one of these objects 
> showed that its future variable is not cancelled but that by tracing though 
> the callback variables there is a cancelled Future further up the chain. That 
> cancelled Future object is one returned by execute because its callback is 
> one of our classes. So it appears that the library is unaware that cancel has 
> been called on the Future returned by execute() and keeps a reference to all 
> resources allocated to the request.
> Instead cancelling the Future should release any resources allocated to the 
> request and should also cancel execution if it has started.
> We regard this as a very urgent issue because it causes our application to 
> crash. We realise that improving the responsiveness of our web site will 
> alleviate the problem somewhat but the library shouldn't leak memory. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to