A lot of factors can impact the performance of an application developed in Java programming language. At a high level following areas can be optimized to improve Java application performance.
JVM
Java program
Connectivity optimizations
Benefits:
Dis-advantages:
During garbage collection process, the JVM may stop all the application process threads from execution. This freezing of application processes is termed as 'Stop The World'
Java heap is structured into following sections, also called as generations.
New Generation - All new objects created by a Java program are put into the new generation section of the heap. Garbage collection runs on the new generation and removes all short-lived objects.
New generation section is further split into two sections. Eden space and Survivor space.
Old Generation - Objects that survive the survivor section of the new generation section are promoted to the old generation section. The old generation section is much larger than the new generation. A separate garbage collection process, also called as FullGC, happens in the Old generation section.
PermGen - JVM uses PermGen to store the meta-data about classes.
Following are some of the algorithms available for garbage collection
Serial GC - Designed for single CPU machines. Stops all application processes during garbage collection. Goes through all objects, marks objects for garbage collection, removes them.
Parallel GC - Similar to Serial, except used multiple threads for garbage collection.
Concurrent Mark Sweep - Concurrent Mark Sweep does most of the garbage collection concurrently with the application processes. Hence, the amount of time that all application process are completely stopped are greatly reduced.
G1GC (Garbage first garbage collector) - ...
*** See complete answer in the Java Interview Guide
The finalize() method is called by the garbage collector on an object before it releases the object from memory. The garbage collector releases an object ...
*** See complete answer in the Java Interview Guide
Following are some common flags you would set to tune JVM
*** See complete answer in the Java Interview Guide
Memory leaks in a Java program happen when references to objects are not released. This fills up the heap space and ...
*** See complete answer in the Java Interview Guide