Initializing all Java classes at Start-Up
Jean-Marie Dautelle writes "Java classes are initialized at first-use only which can introduce significant runtime delays detrimental to real-time or games applications (for which accurate scheduling is often required).
To solve this problem, the latest open-source Javolution library supports initialization of all Java classes at start-up (e.g.
javolution.lang.ClassInitializer.initializeAll(); // Initialize runtime classes (rt.jar) and all classes in classpath).
Note: Runtime class initialization (rt.jar) takes typically a few seconds and about 3 Mbytes of memory."
"A few seconds" and 3MB of memory for rt.jar sound nice but I wonder how timings and memory consumption would look like with a couple of more libraries in the CLASSPATH, how about a full Eclipse environment?
The problem with Java startup times is that every Java app loads it's own complete runtime environment. This is not easy to fix, since many apps depend on the fact that they get their own.
db4o - open source object database for Java and
The advantage of doing eager initialization is predictability, and in the case where almost all classes get initialized sooner or later (which would be very rare considering the size of the Java API) a slight performance increase.
Maybe some kinds of games would benefit from this, but almost all other applications would benefit from more lazy initialization, not less.
Try out fish, the friendly interactive shell.
Let's see. Submitter of story: Jean-Marie Dautelle. Javolution project owner: Jean-Marie Dautelle.
Windows is like decaf - it tastes like the real thing, but it won't get you through the day.
I speed up my java load times by using this tecnique that I like to call C++.
.NET is somewhat different, the design part is still the same. It gets worse in VB.NET (please don't start flaming) where people can have project level imports. It even bothered me in C++ when someone would lets say remove functionality but leave all the imports/#define behind. Today I came accross this problem in ASP.NET an webpage:
On a more serious note, one of the problems with load times I have noticed in a lot of Java is that people unnecessarily include namespaces where they don't need/use them. Sometimes there's no reason to go into another library when there's an equivalent function in one you're already using and there's certainly no need to reference things you don't use. That also creates a design problem in addition to the performance issue IMO because although it's not hurting too bad, it's a violation of least privilege.
This post reminds me of some other related problems that occur in other languages both design and performance related. Although the issue with
imports System.Web.UI (only namespace used)
imports System.Text (not used!)
imports System.XML.Serialization (not used!)
imports System.Threading (not used!)