Java Performance

Java Performance Notes

Performance is an important and interesting area in Java programming language. However, at least few of these might be JVM specific, and hence use them with care and good understanding.

Out of Memory Errors in Java

This note will provide a quick overview of different out of memory errors you might enounter, how to identify the type of the error, how you can analyze them further and how you can try to avoid them in future. We will also see some JVM flags which can help us in this analysis.

We will see the four main cases of out of memory error:

  1. Not enough native memory for JVM

  2. Not enough permgen/metaspace memory in heap

  3. Not enough heap memory

Finalize Method in Java - Why Not To Use, Limited Use Cases and Alternatives

Every class in Java has a finalize() method inherited from the Object class, which will be called by GC when the object is eligible for garbage collection. Main purpose of this method is to perform any cleanup actions before the object is completely discarded by GC. However, the finalize method may take any action, including making this object available again to other threads. The finalize method of class Object does nothing; it simply returns normally.

Soft and Week Reference Object Classes in Java

There are different kinds of references in Java like strong, soft, weak, phantom etc. When you create a normal object using the new keyword and then assign it to a regular type, you are creating a strong reference. Garbage collector will only collect an object if there are no strong references to that object. Less strong references include soft, weak and phantom, and they are defined in the java.lang.ref package.

 

String Interning and Performance Tuning in Java

String interning is a method of storing only one copy of each distinct string value. Strings in Java are immutable and hence this sharing is perfectly safe and give you better performance. The distinct values are stored in a fixed-size hashtable usually referred to as string intern pool or string pool. The single copy of each string is called its 'intern'. You can read more about the basics of String interning with examples @ string-interning-in-java-with-examples.

Just-In-Time (JIT) Compiler Versions - Client, Server and Tiered JVMs

Compilation occuring during program execution is called Just-In-Time compilation. There are 3 versions of the JIT compiler, and they are a 32-bit client version (-client), a 32-bit server version (-server) and a 64-bit server version (-d64). Oracle’s standard JVM implementation (that we download from oracle downloads page) is known as Hotspot JVM. 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!