Tips for improving the performane of Java applications
Submitted by loner on 27 October, 2008 - 1:13pm
- Use Native Methods: The small amount of overheads caused by JNI is usually outweighed by the improved speed of the native function
- Use Buffering on I/O Operations:
BufferedInputStream,BufferedOutputStream,BufferedReader,BufferedWriterreduce the number of I/O operations to be performed. - Avoid Creating New Objects: Reuse objects as much as possible. The more objects, the more memory to create/store them.
- Use
StringBufferinstead of String Concatenations - Avoid
SynchronizedMethods and Blocks - Use
ArrayListandHashMapinstead ofVectorandHashtable:VectorandHashtableare heavily synchronized for thread safety, whileArrayListandHashMap(which provide similar functionality) are not. You can make theseCollectionclasses thread safe by calling static methods within theCollectionclass that create a thread-safe wrapper around a collection. - Use Resource Pooling for Threads, Databases and Network connections
- Make Methods
Final,Static,Private: These enable static binding, which is faster than dynamic binding. - Minimise Subclasses and Method Overriding
What did I say then?
Patriot games just the beginning of Beijing hard ball (7 years 51 weeks ago):
The writing is on the wall. Forget about the official rhetoric - the depth of discontent within t...
