You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by laredotornado-3 <la...@gmail.com> on 2013/05/03 18:44:05 UTC

Can Maven recover from OutOfMemoryErrors during JUnit test runs?

Hi,

I'm using Maven 3.0.3.  Is it possible to configure Maven or the Surefire
plugin to recover from OutOfMemoryErrors?  I notice with my JUnit tests, if
one test from file A fails with an "OutOfMemoryError," all subsequent tests
in my Maven Junit run (even those from different files) fail with
OutOfMemoryErrors.  When I run the files in isolation (e.g.
"-Dtest=FileATest"), the test runs fine. 

I'm using the Surefire 2.14.1:

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.14.1</version>
			</plugin>

Thanks for any wisdom, - Dave


Here's an example of one of the OutOfMemoryErrors …

Exception in thread "Poller SunPKCS11-Darwin" java.lang.OutOfMemoryError:
Java heap space
        at sun.security.pkcs11.wrapper.PKCS11.C_GetSlotInfo(Native Method)
        at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:767)
        at sun.security.pkcs11.SunPKCS11.access$100(SunPKCS11.java:42)
        at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:700)
        at java.lang.Thread.run(Thread.java:680)





--
View this message in context: http://maven.40175.n5.nabble.com/Can-Maven-recover-from-OutOfMemoryErrors-during-JUnit-test-runs-tp5754845.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can Maven recover from OutOfMemoryErrors during JUnit test runs?

Posted by Andreas Gudian <an...@gmail.com>.
Hi,

The safest option is to configure surefire to spawn a new JVM for each test
class: <reuseForks>false</reuseForks> [1]. That will of cause give you some
considerable bump in the execution time.

Good luck,
Andreas

[1]
http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html


2013/5/3 laredotornado-3 <la...@gmail.com>

> Hi,
>
> I'm using Maven 3.0.3.  Is it possible to configure Maven or the Surefire
> plugin to recover from OutOfMemoryErrors?  I notice with my JUnit tests, if
> one test from file A fails with an "OutOfMemoryError," all subsequent tests
> in my Maven Junit run (even those from different files) fail with
> OutOfMemoryErrors.  When I run the files in isolation (e.g.
> "-Dtest=FileATest"), the test runs fine.
>
> I'm using the Surefire 2.14.1:
>
>                         <plugin>
>                                 <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-surefire-plugin</artifactId>
>                                 <version>2.14.1</version>
>                         </plugin>
>
> Thanks for any wisdom, - Dave
>
>
> Here's an example of one of the OutOfMemoryErrors …
>
> Exception in thread "Poller SunPKCS11-Darwin" java.lang.OutOfMemoryError:
> Java heap space
>         at sun.security.pkcs11.wrapper.PKCS11.C_GetSlotInfo(Native Method)
>         at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:767)
>         at sun.security.pkcs11.SunPKCS11.access$100(SunPKCS11.java:42)
>         at
> sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:700)
>         at java.lang.Thread.run(Thread.java:680)
>
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Can-Maven-recover-from-OutOfMemoryErrors-during-JUnit-test-runs-tp5754845.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Can Maven recover from OutOfMemoryErrors during JUnit test runs?

Posted by Kristian Rosenvold <kr...@gmail.com>.
I don't know about newer jdk versions. If you google-fu tokenPollerProtection
I'm sure you'll end
up with the original tomcat issue, which may contain more details and
references to
sun bug reports.

As far as I can understand, it mostly applies to unloading of applications;
which
would seem to indicate you're going to have memory issues if doing hot
redeployment etc,
probably nothing significant on a production server with conservative
redeployment routines.

Kristian

2013/5/3 laredotornado-3 <la...@gmail.com>

> Thanks for the replies.
>
> Andreas, I added the reuseForks option and combined wiht an increased heap
> size everything runs great.
>
> Kristian, We'll eventually be running our app on Jboss 7.1.1 with Java 6.
> Is the bug you mention somethign Sun addressed in newer JDKs? - Dave
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Can-Maven-recover-from-OutOfMemoryErrors-during-JUnit-test-runs-tp5754845p5754872.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Can Maven recover from OutOfMemoryErrors during JUnit test runs?

Posted by laredotornado-3 <la...@gmail.com>.
Thanks for the replies.

Andreas, I added the reuseForks option and combined wiht an increased heap
size everything runs great.  

Kristian, We'll eventually be running our app on Jboss 7.1.1 with Java 6. 
Is the bug you mention somethign Sun addressed in newer JDKs? - Dave



--
View this message in context: http://maven.40175.n5.nabble.com/Can-Maven-recover-from-OutOfMemoryErrors-during-JUnit-test-runs-tp5754845p5754872.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can Maven recover from OutOfMemoryErrors during JUnit test runs?

Posted by Kristian Rosenvold <kr...@gmail.com>.
Generally, "no"  - we do not recover from memory leaks.

The specific memory leak you're referring to here is actually one of the
well-known jdk memory leaks. I've seen this solved
in tomcat with 'tokenPollerProtection'. Surefire will have the same kind of
leak
if you're using forkmode=never; we don't have the kind of protection tomcat
has (and probably
don't need it!)

Any other forkmode should be immune from this problem, apart from what can
leak inside the
fork itself. Also remember to tweak memory settings with either MAVEN_OPTS
or within the
forked process by <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>

Kristian

2013/5/3 laredotornado-3 <la...@gmail.com>

> Hi,
>
> I'm using Maven 3.0.3.  Is it possible to configure Maven or the Surefire
> plugin to recover from OutOfMemoryErrors?  I notice with my JUnit tests, if
> one test from file A fails with an "OutOfMemoryError," all subsequent tests
> in my Maven Junit run (even those from different files) fail with
> OutOfMemoryErrors.  When I run the files in isolation (e.g.
> "-Dtest=FileATest"), the test runs fine.
>
> I'm using the Surefire 2.14.1:
>
>                         <plugin>
>                                 <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-surefire-plugin</artifactId>
>                                 <version>2.14.1</version>
>                         </plugin>
>
> Thanks for any wisdom, - Dave
>
>
> Here's an example of one of the OutOfMemoryErrors …
>
> Exception in thread "Poller SunPKCS11-Darwin" java.lang.OutOfMemoryError:
> Java heap space
>         at sun.security.pkcs11.wrapper.PKCS11.C_GetSlotInfo(Native Method)
>         at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:767)
>         at sun.security.pkcs11.SunPKCS11.access$100(SunPKCS11.java:42)
>         at
> sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:700)
>         at java.lang.Thread.run(Thread.java:680)
>
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Can-Maven-recover-from-OutOfMemoryErrors-during-JUnit-test-runs-tp5754845.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>