[ Previous | Next | Table of Contents | Index | Library Home |
Performance Management Guide
The following are basic Java performance issues:
- Use StringBuffer instead of string concatenations, when doing
excessive string manipulations to avoid unnecessarily creating objects that
eventually need to be garbage collected.
- Avoid excessive writing to the Java console to reduce the cost of string
manipulations, text formatting, and output.
- Avoid the costs of object creation and manipulation by using primitive
types for variables when necessary.
- Cache frequently used objects to reduce the amount of garbage collection
needed, and avoid the need to repeatedly create the objects.
- Group native operations to reduce the number of Java Native Interface
(JNI) calls when possible.
- Use synchronized methods only when necessary, to limit the multitasking in
the JVM and operating system.
- Avoid invoking the garbage collector unless necessary. If you must
invoke it, do so only during idle time or some noncritical phase.
- Use int instead of long whenever possible, because
32-bit operations are executed faster than 64-bit.
- Declare methods as final whenever possible. Final methods are
handled better by the JVM.
- Use the key word static final when creating constants in order
to reduce the number of times the variables need to be initialized.
- Avoid unnecessary "casts" and "instanceof" references because casting in
Java is not done at compile time but at run time.
- Avoid the use of vectors whenever possible when an array will
- Add and delete items from the end of the vector for better
- Compile Java files with the -O option.
[ Previous | Next | Table of Contents | Index |
Library Home |