java代码结构优化 java代码性能优化( 二 )


Java 的最大优势不是体现在执行速度上,所以对Compiler的要求并不如c++那样高,代码级的优化还需要程序员本身的功底 。
贴个java的运行参数:
Usage: java [-options] class [args...]
(to execute a class)
orjava [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-clientto select the "client" VM
-serverto select the "server" VM
-hotspotis a synonym for the "client" VM[deprecated]
The default VM is client.
-cp class search path of directories and zip/jar files
-classpath class search path of directories and zip/jar files
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-Dname=value
set a system property
-verbose[:class|gc|jni]
enable verbose output
-versionprint product version and exit
-version:value
require the specified version to run
-showversionprint product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -helpprint this help message
-Xprint help on non-standard options
-ea[:packagename...|:classname]
-enableassertions[:packagename...|:classname]
enable assertions
-da[:packagename...|:classname]
-disableassertions[:packagename...|:classname]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:libname[=options]
load native agent library libname, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:pathname[=options]
load native agent library by full pathname
-javaagent:jarpath[=options]
load Java programming language agent, see
java.lang.instrument
-Xmixedmixed mode execution (default)
-Xintinterpreted mode execution only
-Xbootclasspath:directories and zip/jar files separated by ;
set search path for bootstrap classes and resources
-Xbootclasspath/a:directories and zip/jar files separated by ;
append to end of bootstrap class path
-Xbootclasspath/p:directories and zip/jar files separated by ;
prepend in front of bootstrap class path
-Xnoclassgcdisable class garbage collection
-Xincgcenable incremental garbage collection
-Xloggc:filelog GC status to a file with time stamps
-Xbatchdisable background compilation
-Xmssizeset initial Java heap size
-Xmxsizeset maximum Java heap size
-Xsssizeset java thread stack size
-Xprofoutput cpu profiling data
-Xfutureenable strictest checks, anticipating future default
-Xrsreduce use of OS signals by Java/VM (see
documentation)
-Xcheck:jniperform additional checks for JNI functions
-Xshare:offdo not attempt to use shared class data
-Xshare:autouse shared class data if possible (default)
-Xshare:onrequire using shared class data, otherwise fail.
Java虚拟机(JVM)参数配置说明
在Java、J2EE大型应用中,JVM非标准参数的配置直接关系到整个系统的性能 。
JVM非标准参数指的是JVM底层的一些配置参数,这些参数在一般开发中默认即可,不需
要任何配置 。但是在生产环境中,为了提高性能,往往需要调整这些参数,以求系统达
到最佳新能 。
另外这些参数的配置也是影响系统稳定性的一个重要因素,相信大多数Java开发人员都
见过“OutOfMemory”类型的错误 。呵呵,这其中很可能就是JVM参数配置不当或者就没
有配置没意识到配置引起的 。
为了说明这些参数,还需要说说JDK中的命令行工具一些知识做铺垫 。
首先看如何获取这些命令配置信息说明:
假设你是windows平台,你安装了J2SDK,那么现在你从cmd控制台窗口进入J2SDK安装目

推荐阅读