java的那些参数
来源:互联网 发布:windows平板电脑设置 编辑:程序博客网 时间:2024/05/17 01:36
一、基本参数
-server:一定要作为第一个参数,在多个CPU时性能佳。turns on the optimizing JIT along with a few other "server-class" settings. Generally you get the best performance out of this setting. The default VM is-client, unless you're on 64-bit (it only has-server).
二、非标准参数
-Xms:初始Heap大小,使用的最小内存,cpu性能高时此值应设的大一些
-Xmx:java heap最大值,使用的最大内存
上面两个值是分配JVM的最小和最大内存,取决于硬件物理内存的大小,建议均设为物理内存的一半。
-XX:PermSize:设定内存的永久保存区域
-XX:MaxPermSize:设定最大内存的永久保存区域
-XX:MaxNewSize:
-Xss:每个线程的Stack大小
-Xss 15120 这使得JBoss每增加一个线程(thread)就会立即消耗15M内存,而最佳值应该是128K,默认值好像是512k.
+XX:AggressiveHeap 会使得 Xms没有意义。这个参数让jvm忽略Xmx参数,疯狂地吃完一个G物理内存,再吃尽一个G的swap。
-Xmn:young generation的heap大小,一般设置为Xmx的3、4分之一
内存回收(GC)相关的参数:
-verbose:gc 现实垃圾收集信息
-Xloggc:gc.log 指定垃圾收集日志文件
-XX:+UseParNewGC :缩短minor收集的时间
-XX:+UseConcMarkSweepGC :缩短major收集的时间
提示:此选项在Heap Size 比较大而且Major收集时间较长的情况下使用更合适。
-Xshare:dump can help improve startup performance on some installations. When run as root (or whatever user you have the JVM installed as) it will dump a shared-memory file to disk containing all of the core class data. This file is much faster to load then re-verifying and re-loading all the individual classes, and once in memory it's shared by all JVMs on the system. Note that-Xshare:off, -Xshare:on, -Xshare:auto set whether "Class Data Sharing" is enabled, and it's not available on the-server VM or on 64-bit systems. Mac users: you're already using Apple's version of this feature, upon which Hotspot's version is based.
三、实验性的参数?
- -XX:+UseParallelGC turns on the parallel young-generation garbage collector. This is a stop-the-world collector that uses several threads to reduce pause times. There's also-XX:+UseParallelOldGC to use a parallel collector for the old generation, but it's generally only useful if you often have large numbers of old objects getting collected.
- -XX:+UseConcMarkSweepGC turns on the concurrent mark-sweep collector. This one runs most GC operations in parallel to your application's execution, reducing pauses significantly. It still stops the world for its compact phase, but that's usually quicker than pausing for the whole set of GC operations. This is useful if you need to reduce the impact GC has on an application run and don't mind that it's a little slower than the full stop-the-world versions. Also, you obviously would need multiple processors to see full effect. (Incidentally, if you're interested in GC tuning, you should look atJava SE 6 HotSpot Virtual Machine Garbage Collection Tuning. There's a lot more there.)
- -XX:NewRatio=# sets the desired ratio of "new" to "old" generations in the heap. The defaults are 1:12 in the-client VM and 1:8 in the -server VM. You often want a higher ratio if you have a lot more transient data flowing through your application than long-lived data. For example, Ruby's high object churn often means a lower NewRatio (i.e. larger "new" versus "old") helps performance, since it prevents transient objects from getting promoted to old generations.
- -XX:MaxPermSize=###M sets the maximum "permanent generation" size. Hotspot is unusual in that several types of data get stored in the "permanent generation", a separate area of the heap that is only rarely (or never) garbage-collected. The list of perm-gen hosted data is a little fuzzy, but it generally contains things like class metadata, bytecode, interned strings, and so on (and this certainly varies across Hotspot versions). Because this generation is rarely or never collected, you may need to increase its size (or turn on perm-gen sweeping with a couple other flags). In JRuby especially we generate a lot of adapter bytecode, which usually demands more perm gen space.
- -XX:+PrintCompilation prints out the name of each Java method Hotspot decides to JIT compile. The list will usually show a bunch of core Java class methods initially, and then turn to methods in your application. In JRuby, it eventually starts to show Ruby methods as well.
- -XX:+PrintGCDetails includes the data from-verbose:gc but also adds information about the size of the new generation and more accurate timings.
- -XX:+TraceClassLoading and -XX:+TraceClassUnloading print information class loads and unloads. Useful for investigating if you have a class leak or if old classes (like JITed Ruby methods in JRuby) are getting collected or not.
四、环境变量
参考网页:
http://www.51testing.com/?uid-16403-action-viewspace-itemid-137851
http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html
http://q-redux.blogspot.com/2011/01/inspecting-hotspot-jvm-options.html
http://javarevisited.blogspot.com/2011/11/hotspot-jvm-options-java-examples.html
- java的那些参数
- java的那些参数
- Java中关于可变长参数的那些事
- java设置jvm参数,我趟过的那些坑
- Java中关于可变长参数的那些事[参数中使用省略号的情况]
- Java中关于可变长参数的那些事[参数中使用省略号的情况]
- 参数传递的那些事
- Java的那些故事
- JAVA的那些池子
- JAVA的那些事儿
- 那些年,关于 Java 的那些事儿
- 不知道对象的传递那些参数
- C++那些细节--函数的默认参数
- 自学QT之setWindowFlags的那些参数
- Java 内存的那些事
- java上班的那些日子
- Java String的那些事儿
- 那些丑陋的Java API
- 一个简单的makefile示例及其注释
- 小试JsUnit
- android 判断是否在桌面
- C++中的虚函数和纯虚函数用法
- 内存分页排序
- java的那些参数
- 变量的作用域
- In any event, here are some other good online sources for OpenGL information:
- GridView RowCommand() 中 获取当前行 控件
- javascript与java,连接字符串
- javascript正则验证大全
- 访问控制符的注意点
- eclipse error "'.JETEmitters' is missing required library"
- GoAgent的安全证书问题(java编程)