Java_6_JVM参数选项大全.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《Java_6_JVM参数选项大全.doc》由会员分享,可在线阅读,更多相关《Java_6_JVM参数选项大全.doc(18页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Java虚拟机(JVM)参数配置说明在Java、J2EE大型应用中,JVM非标准参数的配置直接关系到整个系统的性能。JVM非标准参数指的是JVM底层的一些配置参数,这些参数在一般开发中默认即可,不需要任何配置。但是在生产环境中,为了提高性能,往往需要调整这些参数,以求系统达到最佳新能。另外这些参数的配置也是影响系统稳定性的一个重要因素,相信大多数Java开发人员都见过“OutOfMemory”类型的错误。呵呵,这其中很可能就是JVM参数配置不当或者就没有配置没意识到配置引起的。为了说明这些参数,还需要说说JDK中的命令行工具一些知识做铺垫。首先看如何获取这些命令配置信息说明:假设你是windo
2、ws平台,你安装了J2SDK,那么现在你从cmd控制台窗口进入J2SDK安装目录下的bin目录,然后运行java命令,出现如下结果,这些就是包括java.exe工具的和JVM的所有命令都在里面。-D:j2sdk15binjavaUsage: java -options class args. (to execute a class) or java -options -jar jarfile args. (to execute a jar file)where options include: -client to select the client VM -server to select
3、the server VM -hotspot is a synonym for the client VM deprecated The default VM is client. -cp -classpath A ; separated list of directories, JAR archives, and ZIP archives to search for class files. -D= set a system property -verbose:class|gc|jni enable verbose output -version print product version
4、and exit -version: require the specified version to run -showversion print product version and continue -jre-restrict-search | -jre-no-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea:.|: -enableasserti
5、ons:.|: enable assertions -da:.|: -disableassertions:.|: disable assertions -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:= load native agent library , e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof
6、=help -agentpath:= load native agent library by full pathname -javaagent:= load Java programming language agent, see java.lang.instrument-在控制台输出信息中,有个-X(注意是大写)的命令,这个正是查看JVM配置参数的命令。其次,用java -X 命令查看JVM的配置说明:运行后如下结果,这些就是配置JVM参数的秘密武器,这些信息都是英文的,为了方便阅读,我根据自己的理解翻译成中文了(不准确的地方还请各位博友斧正)-D:j2sdk15binjava -X -X
7、mixed mixed mode execution (default) -Xint interpreted mode execution only -Xbootclasspath: set search path for bootstrap classes and resources -Xbootclasspath/a: append to end of bootstrap class path -Xbootclasspath/p: prepend in front of bootstrap class path -Xnoclassgc disable class garbage colle
8、ction -Xincgc enable incremental garbage collection -Xloggc: log GC status to a file with time stamps -Xbatch disable background compilation -Xms set initial Java heap size -Xmx set maximum Java heap size -Xss set java thread stack size -Xprof output cpu profiling data -Xfuture enable strictest chec
9、ks, anticipating future default -Xrs reduce use of OS signals by Java/VM (see documentation) -Xcheck:jni perform additional checks for JNI functions -Xshare:off do not attempt to use shared class data -Xshare:auto use shared class data if possible (default) -Xshare:on require using shared class data
10、, otherwise fail.The -X options are non-standard and subject to change without notice.-JVM配置参数中文说明:-1、-Xmixed mixed mode execution (default)混合模式执行2、-Xint interpreted mode execution only解释模式执行3、-Xbootclasspath: set search path for bootstrap classes and resources设置zip/jar资源或者类(.class文件)存放目录路径3、-Xbootc
11、lasspath/a: append to end of bootstrap class path追加zip/jar资源或者类(.class文件)存放目录路径4、-Xbootclasspath/p: prepend in front of bootstrap class path预先加载zip/jar资源或者类(.class文件)存放目录路径5、-Xnoclassgc disable class garbage collection关闭类垃圾回收功能6、-Xincgc enable incremental garbage collection开启类的垃圾回收功能7、-Xloggc: log G
12、C status to a file with time stamps记录垃圾回日志到一个文件。8、-Xbatch disable background compilation关闭后台编译9、-Xms set initial Java heap size设置JVM初始化堆内存大小10、-Xmx set maximum Java heap size设置JVM最大的堆内存大小11、-Xss set java thread stack size设置JVM栈内存大小12、-Xprof output cpu profiling data输入CPU概要表数据13、-Xfuture enable stric
13、test checks, anticipating future default执行严格的代码检查,预测可能出现的情况14、-Xrs reduce use of OS signals by Java/VM (see documentation)通过JVM还原操作系统信号15、-Xcheck:jni perform additional checks for JNI functions对JNI函数执行检查16、-Xshare:off do not attempt to use shared class data尽可能不去使用共享类的数据17、-Xshare:auto use shared cla
14、ss data if possible (default)尽可能的使用共享类的数据18、-Xshare:on require using shared class data, otherwise fail.尽可能的使用共享类的数据,否则运行失败The -X options are non-standard and subject to change without notice.-怎么用这这些参数呢?其实所有的命令行都是这么一用,下面我就给出一个最简单的HelloWorl的例子来演示这个参数的用法,非常的简单。HelloWorld.java-public class HelloWorldpub
15、lic static void main(String args) System.out.println(Hello World!);编译并运行:D:j2sdk15binjavac HelloWorld.javaD:j2sdk15binjava -Xms256M -Xmx512M HelloWorldHello World!呵呵,这下满足了吧!实践:在大型系统或者应用中配置JVM参数比如你配置IDE工具的参数,常见的有IDEA、Eclipse,这个是在一个配置文件中指定即可。如果你要在J2EE环境中配置这些参数,那么你需要在J2EE应用服务器或者Servlet容器相关启动参数设置处指定,其启动
16、文件中来配置,Tomcat是在catalina.bat中配置,weblogic和websphere是在其他地方,具体我就说了,相信玩过的这些大型服务器的人都知道,没玩过的看看这篇文章,玩玩就知道了,呵呵。另外常常有人问到jdk的一些相关命令用法,其实,当你看到这里的时候,你应该知道如何获取这些命令的用法了。如果你还不会,那么,建议你去学学DOS,我是没辙了。如果你会这些,还是没有看明白,那么你赶紧学学英语吧,这样你就能看懂了。另外:我在最后给出常用的几个Java命令行说明,以供参考:(1)、javac用法:javac 其中,可能的选项包括: -g 生成所有调试信息 -g:none 不生成任何调
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java_6_JVM 参数 选项 大全
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内