From issues-return-67050-archive-asf-public=cust-asf.ponee.io@commons.apache.org Tue Mar 20 14:23:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id B090118067E for ; Tue, 20 Mar 2018 14:23:04 +0100 (CET) Received: (qmail 86749 invoked by uid 500); 20 Mar 2018 13:23:03 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 86738 invoked by uid 99); 20 Mar 2018 13:23:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2018 13:23:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 24A171A01D5 for ; Tue, 20 Mar 2018 13:23:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -101.511 X-Spam-Level: X-Spam-Status: No, score=-101.511 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 46nsO2Hc20my for ; Tue, 20 Mar 2018 13:23:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id BDAB65F5B7 for ; Tue, 20 Mar 2018 13:23:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 16A31E0D6E for ; Tue, 20 Mar 2018 13:23:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 7C3E1214C3 for ; Tue, 20 Mar 2018 13:23:00 +0000 (UTC) Date: Tue, 20 Mar 2018 13:23:00 +0000 (UTC) From: "Christoph Ludwig (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COMPRESS-446) Resource Leak in ParallelScatterZipCreator#writeTo(ZipArchiveOutputStream) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COMPRESS-446?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D16= 406315#comment-16406315 ]=20 Christoph Ludwig commented on COMPRESS-446: ------------------------------------------- I think shutting down the executor service in a finally block is fine - thi= s way all threads are closed and the objects reachable from there get a cha= nce to be re-claimed. In addition, I think it would be worthwhile to document explicitly that the= ZIP creation fails irrecoverably if any of the futures throws an excepti= on. It does not come as a surprise, of course, but It helps if the document= ation is clear on this. =C2=A0 > Resource Leak in ParallelScatterZipCreator#writeTo(ZipArchiveOutputStream= ) > -------------------------------------------------------------------------= - > > Key: COMPRESS-446 > URL: https://issues.apache.org/jira/browse/COMPRESS-446 > Project: Commons Compress > Issue Type: Bug > Components: Archivers > Affects Versions: 1.16.1 > Environment: The application was running inside a Docker containe= r, the JVM had about 1.7 GByte heap space. > Reporter: Christoph Ludwig > Priority: Major > > Before it does anything else, {{ParallelScatterZipCreator#writeTo(ZipArch= iveOutputStream)}} loops over all futures returned by the creator`s executo= r service and calls {{Future#get()}}. This will block until the future's co= mputation is completed, respectively - i.e., until all entries have been wr= itten to the thread-local scatter streams. > However, if the computation of a future fails, then {{Future#get()}} can = also throw an exception. This exception escapes {{ParallelScatterZipCreator= #writeTo(ZipArchiveOutputStream)}} before the executor service is shut down= . The latter means that also the thread-local variables in the executor ser= vice's threads and all objects referenced by them continue to exist and can= not be reclaimed by the GC. > I encountered this situation when - while processing an archive with 130,= 000 documents - the JVM threw an {{OutOfMemoryError}}. The application was = not able to recover from this OOM error because most of the heap was occupi= ed by objects reachable from the executor service's threads. > Of course, the OOM is mostly the fault of my own code; I will be able to = work around the "leaked" executor service because I supply it in the first = place and can therefore shut it down if I detect an error situation. =20 > The effect would be the same, though, if, say, {{Future#get()}} throws an= {{InterruptedException}}. Therefore, {{ParallelScatterZipCreator#writeTo(Z= ipArchiveOutputStream)}} should either shut down and release all resources= if it cannot complete its task due to an Exception thrown by a future or i= t should offer a reasonable recovery strategy.=20 -- This message was sent by Atlassian JIRA (v7.6.3#76005)