Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 35748 invoked from network); 11 Dec 2007 20:21:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 20:21:24 -0000 Received: (qmail 36640 invoked by uid 500); 11 Dec 2007 20:21:12 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 36594 invoked by uid 500); 11 Dec 2007 20:21:12 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 36583 invoked by uid 99); 11 Dec 2007 20:21:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 12:21:12 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andreask@fredhopper.com designates 82.94.15.138 as permitted sender) Received: from [82.94.15.138] (HELO smtp.fredhopper.com) (82.94.15.138) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 20:20:51 +0000 Received: from [192.168.0.48] (tiamaria.ams.fredhopper.com [192.168.0.48]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.fredhopper.com (Postfix) with ESMTP id AEB6D1C6A75 for ; Tue, 11 Dec 2007 21:20:52 +0100 (CET) Subject: OutOfMemory in JUnitTestRunner From: Andreas Kohn To: dev@ant.apache.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Bt5nu+y2MpJ0V4IWG0kJ" Date: Tue, 11 Dec 2007 21:20:52 +0100 Message-Id: <1197404452.2700.24.camel@tiamaria.ams.fredhopper.com> Mime-Version: 1.0 X-Mailer: Evolution 2.12.2 (2.12.2-2.fc8) X-Virus-Checked: Checked by ClamAV on apache.org --=-Bt5nu+y2MpJ0V4IWG0kJ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, we observe a very strange problem in the JUnitTestRunner: It runs out of memory with the default settings, with the following stack trace: [junit] [Unloading class sun.reflect.GeneratedConstructorAccessor2] [junit] [Unloading class sun.reflect.GeneratedConstructorAccessor3] [junit] [Unloading class sun.reflect.GeneratedConstructorAccessor1] [junit] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space [junit] at java.lang.StringCoding $StringDecoder.decode(StringCoding.java:133) [junit] at java.lang.StringCoding.decode(StringCoding.java:173) [junit] at java.lang.StringCoding.decode(StringCoding.java:185) [junit] at java.lang.String.(String.java:571) [junit] at java.lang.String.(String.java:594) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestR= unner.java:449) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTe= stRunner.java:912) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTest= Runner.java:766) When this happens, JUnitTestRunner is running: if (startTestSuiteSuccess) { sendOutAndErr(new String(outStrm.toByteArray()), new String(errStrm.toByteArray())); } The outStrm has captured roughly 23M of data at the moment, which will be copied first for ByteArrayOutputStream.toByteArray(), and then in String. -> StringDecoder.decode() again.=20 So at the end, we have 3 times these 23M lying around, blowing away or VM.=20 An immediate improvement would be to use outStrm.toString() directly, which would copy the buffer only once. I can open a bug report in the issue tracker, but what would you need as data points there? Regards, -- Andreas --=-Bt5nu+y2MpJ0V4IWG0kJ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHXvEkYucd7Ow1ygwRAiyYAKCSulaGk2ypFVl4eYde+gS/YDjwOACfQXdE YN4BesdKpR9hbn2/Uy+sufk= =z56e -----END PGP SIGNATURE----- --=-Bt5nu+y2MpJ0V4IWG0kJ--