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 B243C200C83 for ; Sun, 28 May 2017 21:41:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B0DC8160BCC; Sun, 28 May 2017 19:41:20 +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 032BF160BAF for ; Sun, 28 May 2017 21:41:19 +0200 (CEST) Received: (qmail 44502 invoked by uid 500); 28 May 2017 19:41:12 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 44489 invoked by uid 99); 28 May 2017 19:41:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 May 2017 19:41:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 5A039C0362 for ; Sun, 28 May 2017 19:41:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3 X-Spam-Level: *** X-Spam-Status: No, score=3 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id M-1bIKEsz3MZ for ; Sun, 28 May 2017 19:41:05 +0000 (UTC) Received: from orange.it-room.net (antispam.it-room.net [78.142.189.74]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id C35A35F297 for ; Sun, 28 May 2017 19:41:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by orange.it-room.net (Postfix) with ESMTP id C85211422C7; Sun, 28 May 2017 21:40:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at it-room.net Received: from orange.it-room.net ([127.0.0.1]) by localhost (orange.it-room.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uFsdU4bgUh2B; Sun, 28 May 2017 21:40:57 +0200 (CEST) Received: from [192.168.0.17] (80-108-101-200.cable.dynamic.surfer.at [80.108.101.200]) by orange.it-room.net (Postfix) with ESMTPSA id 5FF4C1422B0; Sun, 28 May 2017 21:40:57 +0200 (CEST) From: Siegfried Goeschl Message-Id: <94F3748D-83C4-4E3E-9489-F0570CF779DD@it20one.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_E8EF1546-A733-494A-A465-C1B6F8ABE091" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Proper use of Executors Date: Sun, 28 May 2017 21:41:01 +0200 In-Reply-To: Cc: cgamache@gmail.com To: Commons Users List References: X-Mailer: Apple Mail (2.3273) archived-at: Sun, 28 May 2017 19:41:20 -0000 --Apple-Mail=_E8EF1546-A733-494A-A465-C1B6F8ABE091 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Chris, there are couple of things to consider * You are using a PumpStreamHander but the STDERR is not consumed. Each = process has an internal buffer (size depends on the OS) and when the = buffer is full any write to STDERR is blocked * That could happen if the process being executed actually writes some = error messages :-) * Are you 100% sure that the processes will terminate? See = ExecuteWatchdog * You might habe a look at ProcessDestroyer to cleanup during shutdown Thanks in advance, Siegfried Goeschl > On 27 May 2017, at 14:27, Chris Gamache wrote: >=20 > Hi all, >=20 > I'm using org.apache.commons:commons-exec:1.3 on Java 8. >=20 > I'm having an issue where my Tomcat server is bleeding out hundreds of > threads and all of the memory in the form of Executors that I'm = running but > don't seem to be closing down ... When the server finally grinds to a = halt > I have to restart. When I do it looks like this at shutdown time: >=20 > >=20 > 27-May-2017 07:56:21.631 WARNING [localhost-startStop-11] > = org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads = The > web application [ROOT##000252] appears to have started a thread named = [Exec > Default Executor] but has failed to stop it. This is very likely to = create > a memory leak. Stack trace of thread: > java.lang.Object.wait(Native Method) > java.lang.Object.wait(Object.java:502) > java.lang.UNIXProcess.waitFor(UNIXProcess.java:396) > = org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.ja= va:364) > = org.apache.commons.exec.DefaultExecutor.access$200(DefaultExecutor.java:48= ) > = org.apache.commons.exec.DefaultExecutor$1.run(DefaultExecutor.java:200) > java.lang.Thread.run(Thread.java:745) >=20 > 27-May-2017 07:56:21.633 WARNING [localhost-startStop-11] > = org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads = The > web application [ROOT##000252] appears to have started a thread named = [Exec > Stream Pumper] but has failed to stop it. This is very likely to = create a > memory leak. Stack trace of thread: > java.io.FileInputStream.readBytes(Native Method) > java.io.FileInputStream.read(FileInputStream.java:255) > java.io.BufferedInputStream.fill(BufferedInputStream.java:246) > java.io.BufferedInputStream.read1(BufferedInputStream.java:286) > java.io.BufferedInputStream.read(BufferedInputStream.java:345) > java.io.FilterInputStream.read(FilterInputStream.java:107) > org.apache.commons.exec.StreamPumper.run(StreamPumper.java:107) > java.lang.Thread.run(Thread.java:745) >=20 > >=20 > And my thread dump is a mile long. >=20 > I am certainly willing to concede I'm Doing It Wrong(tm) ... Here's = the > relevant code. It is called from a regular method in a regular class, > nothing fancy: >=20 > CommandLine cmdLine =3D CommandLine.parse(command.toString()); > DefaultExecutor executor =3D new DefaultExecutor(); > PumpStreamHandler esh =3D new PumpStreamHandler(os,null,is); > executor.setStreamHandler(esh); > executor.execute(cmdLine); >=20 > `is` and `os` are passed in on the constructor. Their opens and closes = are > managed well and cleaned up on the outside of this class... > Are there further steps I'm missing to ensure the threads I'm creating = are > getting shut down properly and the resources they are using are being > returned? >=20 > Any help is much appreciated. --Apple-Mail=_E8EF1546-A733-494A-A465-C1B6F8ABE091--