Version 3 (modified by joshuadf, 10 years ago) (diff)


Java Anti-Patterns - some efficiency notes

Local Variable Usage

If you need a StringBuffer? or Collection for a temporary local variable, use the less expensive version:

Local Thread-safe
ArrayList Vector
HashMap Hashtable
StringBuilder StringBuffer

JVM Options

Here's a way to make the Sun server JVM take some extra time reserving memory (used in MindSeer and some Tomcats):

JAVA_OPTS="-server -Xmx384m -Xms384m -XX:GCTimeLimit=95 -XX:GCTimeRatio=49"

Another problem is webapps using up the perm gen space, see #15; you can increase with

JAVA_OPTS="-XX:PermSize=128m -XX:MaxPermSize=256m"