You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Andreas Kohn <an...@fredhopper.com> on 2007/12/11 21:20:52 UTC

OutOfMemory in JUnitTestRunner

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.<init>(String.java:571)
[junit]     at java.lang.String.<init>(String.java:594)
[junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:449)
[junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
[junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.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.<init> -> StringDecoder.decode() again. 
So at the end, we have 3 times these 23M lying around, blowing away or
VM. 

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

Re: OutOfMemory in JUnitTestRunner

Posted by Stefan Bodewig <bo...@apache.org>.
Andreas Kohn <an...@fredhopper.com> writes:

> On Tue, 2007-12-11 at 21:20 +0100, Andreas Kohn wrote:
>> Hi,
>> 
>> we observe a very strange problem in the JUnitTestRunner: It runs out of
>> memory with the default settings [...]
>
> What's the exact process for reporting a bug to ant? What information do
> you always need? Is there a FAQ page which I can use?

<http://ant.apache.org/problems.html>

> Also, is there a roadmap for the Junit pieces? I've seen some mails
> around that indicate major changes there, so may be my problem is
> already addressed somehow.

There are proposals talking about major(?) changes to the XML output
<junitreport> generates, but none that would affect <junit> that I was
aware of.

Some while ago there have been talks about handing over the junit task
to the JUnit folks, but this has never really taken off.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: OutOfMemory in JUnitTestRunner

Posted by Andreas Kohn <an...@fredhopper.com>.
On Tue, 2007-12-11 at 21:20 +0100, Andreas Kohn wrote:
> Hi,
> 
> we observe a very strange problem in the JUnitTestRunner: It runs out of
> memory with the default settings [...]

What's the exact process for reporting a bug to ant? What information do
you always need? Is there a FAQ page which I can use?

Also, is there a roadmap for the Junit pieces? I've seen some mails
around that indicate major changes there, so may be my problem is
already addressed somehow.

Regards,
--
Andreas

> --
> Andreas

Re: OutOfMemory in JUnitTestRunner

Posted by Stefan Bodewig <bo...@apache.org>.
Andreas Kohn <an...@fredhopper.com> writes:

> I can open a bug report in the issue tracker,

You could even provide a patch that fixes the problem 8-)  Given that
you think you've identified the problem - and that the change doesn't
look controversial at all.

> but what would you need as data points there?

A unit test that reproduces the OOM exception and doesn't do so after
your patch has been applied would be the best.

Stefan
-- 
http://stefan.samaflost.de/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org