Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D76C6200BA1 for ; Mon, 17 Oct 2016 14:58:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D61EC160AEC; Mon, 17 Oct 2016 12:58:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2A607160AE5 for ; Mon, 17 Oct 2016 14:58:12 +0200 (CEST) Received: (qmail 37094 invoked by uid 500); 17 Oct 2016 12:58:11 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 37083 invoked by uid 99); 17 Oct 2016 12:58:11 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2016 12:58:11 +0000 Received: from ok2c (unknown [213.55.176.238]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 4BB441A00D6 for ; Mon, 17 Oct 2016 12:58:10 +0000 (UTC) Message-ID: <1476709087.7888.2.camel@apache.org> Subject: Re: Memory leak in CloseableHttpAsyncClient? From: Oleg Kalnichevski To: HttpClient User Discussion Date: Mon, 17 Oct 2016 14:58:07 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit archived-at: Mon, 17 Oct 2016 12:58:13 -0000 On Sun, 2016-10-16 at 21:54 +0000, Rob Griffin wrote: > We are using HTTPAsynchClient to send data to our web site from a Java client. > > 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. To me it appears that the library is unaware that cancel has been called on the Future returned by execute() and so keeps a reference to it. > > See [url=https://postimg.org/image/j6zfdrquf/][img]https://s15.postimg.org/qa7atdwa3/Screen_Shot010.jpg[/img][/url][url=https://postimage.org/]image url[/url] > > Regards, > > Rob Griffin Hi Rob Currently cancellation of the response future does not immediately results in cancellation pending connection lease request or termination of the request execution. Feel free to raise an improvement request in Jira. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org