Derrick
Derrick

Reputation: 331

Why does JUnit take so long to launch from Eclipse?

When I run a JUnit test case in Eclipse, it takes 20 seconds just to launch JUnit itself.

In the Progress view it is at 87% for most of this time, stating: Launching: Starting virtual machine...

I have tried increasing the memory allocation to the vm in both eclipse.ini, and also in the Run Configuration for the unit tests (VM arguments: -Xms512m -Xmx1024m), but neither makes a difference.

I'm watching Windows Task Manager when I launch the unit test and I see a new java process get created with only 140K memory, it jumps up to about 20,000K just as JUnit finally starts.

So if I could see the new java process starting with the amount of memory I configured, I could at least rule out JVM memory as the cause of the slow launch. But I'm kind of stuck. I saw a recommendation somewhere to use this, but it also did not work: -Djava.net.preferIPv4Stack=true

Here's my eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.php.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:/Program Files/Java/jdk1.7.0_79/bin/javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms512m
-Xmx1024m
-Djava.net.preferIPv4Stack=true

Upvotes: 9

Views: 2960

Answers (1)

user2023577
user2023577

Reputation: 2121

I know it's a late answer. But that can help others.

Usually it's because the project is afflicted with one of those non-incremental project nature like maven (particularly with a non-incremental maven compile phase plugin) and/or WTP auto publishing, etc. In console view, you can show the maven console, this may reveal what it is doing. Anything related to a remote subclipse/subversion or git during a build would definitely cost some time too.

If you had build automatically, you should not need to build on junit start. Turn all building off on junit launch, but be sure to have the prj built of course (if not automatically then by 'build project' or 'build all').

Also, if you have a project with a ridiculously large number or dependencies jars and you are using a placeholder jar to make command line shorter, then it may be the production of this tmp jar which slows you down, but I doubt it would take 20s.

You may want to try "-noverify" in jvmargs if bypassing class byte code verification is acceptable to you, locally.

Upvotes: 2

Related Questions