Java Performance Tuning Tips

Sometime we need to improve the performance of our application into our code. Below are the recommendations for Java code tuning. Don’t optimize before you know it’s necessary Use a profiler to find the real bottleneck Work on the biggest bottleneck first   Managing Objects Here, idea is used to use garbage collection less frequently either by canonicalization or by references. Lesser number of garbage collection happens, lesser overhead occurs. Avoid creating temporary objects within repeated routines Pre-size collection objects Better to reuse objects than creating Use custom conversion methods for converting data types to reduce creation of temporary objects Canonicalize objects (Replacing multiple objects with single object) whenever required and compare by identity Replace string and other objects with integer constants and compare by identity Better to use primitive types instead of objects for instance variables Use StringBuffer than string concatenation operator Appropriate use of weak, soft references Use cloning… Read more“Java Performance Tuning Tips”