jboss启动时java VM参数设置

jboss服务器中jvm参数的设置:

在$JBOSS_HOME/bin下的run.sh里面存在这么一个设置:

Java代码  收藏代码
  1. # Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower  
  2. if [ "$linux" = "true" ]; then  
  3.    JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"  
  4. fi  

该参数就是设置java VM的参数。我们可以在这里修改这个参数;但更一般的我们会在run.conf里面单独设置java VM的参数,而在这边进行引用。

上面的可以做如下修改

Java代码  收藏代码
  1. # Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower  
  2. if JAVA_OPTS is not setted in run.conf, setting  here; by djq  
  3. if [ "x$JAVA_OPTS" = "x" ]; then  
  4.    JAVA_OPTS="-Xms128m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=36000"  
  5. fi  
  6. if [ "$linux" = "true" ]; then  
  7.    JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"  
  8. fi  

而我们需要可以在run.conf里面单独设置java VM的参数了。(一般情况下我们也不需要在run.sh里面做任何修改,只要在run.conf里面确保该有的参数都有了就ok了)。

附:

run.conf的一个设置:

Java代码  收藏代码
  1. ## -*- shell-script -*- ######################################################  
  2. ##                                                                          ##  
  3. ##  JBoss Bootstrap Script Configuration                                    ##  
  4. ##                                                                          ##  
  5. ##############################################################################  
  6.   
  7. ### $Id: run.conf 62747 2007-05-02 17:43:36Z dimitris@jboss.org $  
  8.   
  9. #  
  10. # This file is optional; it may be removed if not needed.  
  11. #  
  12.   
  13. #  
  14. # Specify the maximum file descriptor limit, use "max" or "maximum" to use  
  15. # the default, as queried by the system.  
  16. #  
  17. # Defaults to "maximum"  
  18. #  
  19. #MAX_FD="maximum"  
  20.   
  21. #  
  22. # Specify the profiler configuration file to load.  
  23. #  
  24. # Default is to not load profiler configuration file.  
  25. #  
  26. #PROFILER=""  
  27.   
  28. #  
  29. # Specify the location of the Java home directory.  If set then $JAVA will  
  30. # be defined to $JAVA_HOME/bin/java, else $JAVA will be "java".  
  31. #  
  32. #JAVA_HOME="/opt/java/jdk"  
  33. #set JAVA_HOME here; by djq  
  34. JAVA_HOME="/jboss/jdk1.5.0_22"  
  35.   
  36. #  
  37. # Specify the exact Java VM executable to use.  
  38. #  
  39. #JAVA=""  
  40.   
  41. #  
  42. # Specify options to pass to the Java VM.  
  43. #  
  44. #if [ "x$JAVA_OPTS" = "x" ]; then  
  45. #   JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"  
  46. #fi  
  47.   
  48. # set options for the JVM; by djq  
  49. if  [ "x$JAVA_OPTS" = "x" ]; then  
  50.    JAVA_OPTS="-Xms1024m -Xmx6120m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=36000"  
  51. fi  
  52.   
  53. # Sample JPDA settings for remote socket debuging  
  54. #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"  
  55.   
  56. # Sample JPDA settings for shared memory debugging   
  57. #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,server=y,suspend=n,address=jboss" 
原文地址:https://www.cnblogs.com/lgqboke/p/6163977.html