Optimization Of Java

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

Reduce number of object creations

In Java, object creations are expensive compared with other compiled object-oriented programming language. This is because object creation involves:
  • memory allocation from heap, which may cause garbage collection when free space is insufficient
  • using meta-data to create the virtual table (larger in Java than, for example, C++, as Java methods are virtual by default)
  • calling constructors

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 in a virtual table. Use of small and simple methods that are called frequently can be quite expensive. If possible, inline code of such method directly at 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.

Myths

There are some myths in performance tuning of Java programs.
  • final modifer with methods or classes reduces the overhead of call of methods - Because the Java compiler cannot know which class will be loaded at runtime, it cannot in-line-expand the methods regardless if they have final or not.

External links

* Java Performance Tuning

 

<< PreviousWord BrowserNext >>
ftl games
indigenous
methodological individualism
edward harcourt
astro creep: 2000 songs of love, destruction and other synthetic delusions of the electric head
economic equilibrium
coordinatorism
pet lamb
wildlife gardening
no war but the class war
radical transparency
sweaty handshake
tokaido main line
sanyo main line
hankyu railway
umeda station
kobe line
hankyu kobe line
sannomiya station
kobe municipal subway
venus envy (ireland band)
neoism
luther blissett
allocation
john lennard jones
julie clary
pickpocketing
world economy
gabriel dumont
etobicoke, ontario
alvin schwartz
pretty hate machine
the fragile
hasty generalization
kim swales
photic sneeze reflex
solar collector
philippine peso
charismatic authority
vascular cambium
cork cambium
sanyo shinkansen
osaka loop line
june carter cash