javagarbage-collectionjava-opts

Is my JAVA_OPTS setting is fine?


I'm tuning my JVM application. JAVA_OPTS I set is like following:

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
JAVA_OPTS="$JAVA_OPTS -server"
JAVA_OPTS="$JAVA_OPTS -Xms2048m"
JAVA_OPTS="$JAVA_OPTS -Xmx2048m"
JAVA_OPTS="$JAVA_OPTS -XX:NewSize=256m"
JAVA_OPTS="$JAVA_OPTS -XX:MaxNewSize=256m"
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m"
JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=256m"

I roughly understood about the Generations. But I'm not sure my setting is appropriate. As far as I understood, the size of new generation is 256 and so remain(1792m) is the size of old generation(because Perm generation is not heap).

Am I right? And is my setting appropriate?


Solution

  • The optimal settings for an average Java application are

    JAVA_OPTS=""
    

    Or why should the Java authors specify defaults everyone would change.

    Without knowing anything about your application and your available memory, there's no point in changing the defaults.

    Actually, -Dfile.encoding=UTF-8 might make sense if you want to use UTF-8 on a system using something else by default (but changing the OS would be better). Forget the others, unless you know how much memory you'll need (and then use -Xmx and still forget the remaining ones).