Submitted by heartin on Mon, 10/05/2015 - 22:08
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.
Submitted by heartin on Wed, 08/20/2014 - 22:04
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:
Not enough native memory for JVM
Not enough permgen/metaspace memory in heap
Not enough heap memory
Submitted by heartin on Thu, 08/07/2014 - 21:43
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.
Submitted by heartin on Thu, 08/07/2014 - 21:37
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.
Submitted by heartin on Wed, 08/06/2014 - 10:45
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.