Main Page | See live article | Alphabetical index

Optimization of Java

This Optimization of Java is a collection of optimization techniques used in the Java programming language.

Table of contents
1 Reduce number of object creations
2 Eliminate simple methods such as accessor method
3 Myths
4 External link

Reduce number of object creations

In Java, object creations are so expensive compared with other compiled object-oriented programming language. It is because in Java, object creation involves:

Eliminate simple methods such as accessor method

Since the Java compiler cannot be completely sure about which method will be called before runtime due to dynamic class loading, each method call involves looking up a method. Use of small and simple methods that are called frequently can be quite expensive. If possible, embed code of such method directly to the point of call.

However, the Java HotSpot VM, introduced in J2SE 1.3, supports method inlining. Any code sections recognized as "hotspots" by this VM will be optimized including inlining of method calls, where it can be done safely.


There are some myths in performance tuning of Java programs.

External link