ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Kohn <>
Subject OutOfMemory in JUnitTestRunner
Date Tue, 11 Dec 2007 20:20:52 GMT

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
[junit]     at java.lang.StringCoding
[junit]     at java.lang.StringCoding.decode(
[junit]     at java.lang.StringCoding.decode(
[junit]     at java.lang.String.<init>(
[junit]     at java.lang.String.<init>(
[junit]     at
[junit]     at
[junit]     at

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.<init> -> StringDecoder.decode() again. 
So at the end, we have 3 times these 23M lying around, blowing away or

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?


View raw message