Eclipse Launcher stays at splash screen for few minutes

Oddly this only happens once after the computer is restarted each time. Subsequently the loading would be much quicker.

Using the profiler the following stack trace is obtained:

main [RUNNABLE, IN_NATIVE] CPU time: 0:00$$$YJP$$doPrivileged(PrivilegedAction)[])[])
java.util.Random.nextLong(), String, File), String, File)
org.eclipse.core.runtime.adaptor.EclipseStarter.startup(String[], Runnable)[], Runnable)
sun.reflect.NativeMethodAccessorImpl.invoke0(Method, Object, Object[])
sun.reflect.NativeMethodAccessorImpl.invoke(Object, Object[])
sun.reflect.DelegatingMethodAccessorImpl.invoke(Object, Object[])
java.lang.reflect.Method.invoke(Object, Object[])
org.eclipse.equinox.launcher.Main.invokeFramework(String[], URL[])

The main thread is stuck in a native File.list() method. From the SeedGenerator source code, there is only one location where it calls the File.list() method, and it happens to match the stack trace — inside an anonymous inner class. From there we can see that it is trying to list the temp folder (system property On Windows, this is the “%USERPROFILE%\Local Settings\Temp” folder.

When I do a directory listing on the folder, I get more than 100,000 temp files. Removing them solves the problem.

From the stack trace Eclipse startup was trying to test whether a folder is writable, by creating a temporary file, which uses a random number generator to generate the filename, in turn using the list of filenames from the TEMP folder as part of the seed. Essentially this problem would surface if you have a TEMP folder with many many files (regardless of size) and perform any of the following:

  • use File.list() on the folder (or any folder with many many files)
  • generate a random number
  • Create a temporary file
  • Starting up Eclipse runtime…

Does Windows cache the directory listing so that it’s faster next time?