编程小贴士

给你的编程提供小点子


java虚拟机启动参数分类详解

java启动参数共分为三类;
其一是标准参数(-),所有的JVM实现都必须实现这些参数的功能,而且向后兼容;
其二是非标准参数(-X),默认jvm实现这些参数的功能,但是并不保证所有jvm实现都满足,且不保证向后兼容;
其三是非Stable参数(-XX),此类参数各个jvm实现会有所不同,将来可能会随时取消,需要慎重使用;

一、标准参数中比较有用的:

verbose
-verbose:class

输出jvm载入类的相关信息,当jvm报告说找不到类或者类冲突时可此进行诊断。
-verbose:gc
输出每次GC的相关情况。
-verbose:jni
输出native方法调用的相关情况,一般用于诊断jni调用错误信息。

 

二、非标准参数又称为扩展参数,一般用到最多的是

-Xms512m  设置JVM促使内存为512m。此值可以设置与-Xmx相同,以避免每次垃圾回收完成后JVM重新分配内存。

-Xmx512m ,设置JVM最大可用内存为512M。

-Xmn200m设置年轻代大小为200M。整个堆大小=年轻代大小 + 年老代大小 + 持久代大小。持久代一般固定大小为64m,所以增大年轻代后,将会减小年老代大小。此值对系统性能影响较大,Sun官方推荐配置为整个堆的3/8。

-Xss128k:

设置每个线程的堆栈大小。JDK5.0以后每个线程堆栈大小为1M,以前每个线程堆栈大小为256K。更具应用的线程所需内存大小进行调整。在相同 物理内存下,减小这个值能生成更多的线程。但是操作系统对一个进程内的线程数还是有限制的,不能无限生成,经验值在3000~5000左右。

-Xloggc:file
 与-verbose:gc功能类似,只是将每次GC事件的相关情况记录到一个文件中,文件的位置最好在本地,以避免网络的潜在问题。
若与verbose命令同时出现在命令行中,则以-Xloggc为准。
-Xprof

跟踪正运行的程序,并将跟踪数据在标准输出输出;适合于开发环境调试。

用-XX作为前缀的参数列表在jvm中可能是不健壮的,SUN也不推荐使用,后续可能会在没有通知的情况下就直接取消了;但是由于这些参数中的确有很多是对我们很有用的,比如我们经常会见到的-XX:PermSize、-XX:MaxPermSize等等;

 

首先来介绍行为参数

参数及其默认值 描述
-XX:-DisableExplicitGC 禁止调用System.gc();但jvm的gc仍然有效
-XX:+MaxFDLimit 最大化文件描述符的数量限制
-XX:+ScavengeBeforeFullGC 新生代GC优先于Full GC执行
-XX:+UseGCOverheadLimit 在抛出OOM之前限制jvm耗费在GC上的时间比例
-XX:-UseConcMarkSweepGC 对老生代采用并发标记交换算法进行GC
-XX:-UseParallelGC 启用并行GC
-XX:-UseParallelOldGC 对Full GC启用并行,当-XX:-UseParallelGC启用时该项自动启用
-XX:-UseSerialGC 启用串行GC
-XX:+UseThreadPriorities 启用本地线程优先级

上面表格中黑体的三个参数代表着jvm中GC执行的三种方式,即串行、并行、并发
串行(SerialGC)是jvm的默认GC方式,一般适用于小型应用和单处理器,算法比较简单,GC效率也较高,但可能会给应用带来停顿;
并行(ParallelGC)是指GC运行时,对应用程序运行没有影响,GC和app两者的线程在并发执行,这样可以最大限度不影响app的运行;
并发(ConcMarkSweepGC)是指多个线程并发执行GC,一般适用于多处理器系统中,可以提高GC的效率,但算法复杂,系统消耗较大;

 

性能调优参数列表:

参数及其默认值 描述
-XX:LargePageSizeInBytes=4m 设置用于Java堆的大页面尺寸
-XX:MaxHeapFreeRatio=70 GC后java堆中空闲量占的最大比例
-XX:MaxNewSize=size 新生成对象能占用内存的最大值
-XX:MaxPermSize=64m 老生代对象能占用内存的最大值
-XX:MinHeapFreeRatio=40 GC后java堆中空闲量占的最小比例
-XX:NewRatio=2 新生代内存容量与老生代内存容量的比例
-XX:NewSize=2.125m 新生代对象生成时占用内存的默认值
-XX:ReservedCodeCacheSize=32m 保留代码占用的内存容量
-XX:ThreadStackSize=512 设置线程栈大小,若为0则使用系统默认值
-XX:+UseLargePages 使用大页面内存

我们在日常性能调优中基本上都会用到以上黑体的这几个属性;

 

调试参数列表:

参数及其默认值 描述
-XX:-CITime 打印消耗在JIT编译的时间
-XX:ErrorFile=./hs_err_pid<pid>.log 保存错误日志或者数据到文件中
-XX:-ExtendedDTraceProbes 开启solaris特有的dtrace探针
-XX:HeapDumpPath=./java_pid<pid>.hprof 指定导出堆信息时的路径或文件名
-XX:-HeapDumpOnOutOfMemoryError 当首次遭遇OOM时导出此时堆中相关信息
-XX:OnError=”<cmd args>;<cmd args>” 出现致命ERROR之后运行自定义命令
-XX:OnOutOfMemoryError=”<cmd args>;<cmd args>” 当首次遭遇OOM时执行自定义命令
-XX:-PrintClassHistogram 遇到Ctrl-Break后打印类实例的柱状信息,与jmap -histo功能相同
-XX:-PrintConcurrentLocks 遇到Ctrl-Break后打印并发锁的相关信息,与jstack -l功能相同
-XX:-PrintCommandLineFlags 打印在命令行中出现过的标记
-XX:-PrintCompilation 当一个方法被编译时打印相关信息
-XX:-PrintGC 每次GC时打印相关信息
-XX:-PrintGC Details 每次GC时打印详细信息
-XX:-PrintGCTimeStamps 打印每次GC的时间戳
-XX:-TraceClassLoading 跟踪类的加载信息
-XX:-TraceClassLoadingPreorder 跟踪被引用到的所有类的加载信息
-XX:-TraceClassResolution 跟踪常量池
-XX:-TraceClassUnloading 跟踪类的卸载信息
-XX:-TraceLoaderConstraints 跟踪类加载器约束的相关信息

103 Responses to “ java虚拟机启动参数分类详解 ”

  1. see pron说道:

    qIJaAZ Major thanks for the article. Will read on

  2. Lung Cleanse说道:

    Thanks again for the blog post.Really thank you! Want more.

  3. I wouldn at mind writing a post or elaborating on a few of the subjects you write with regards to here.

  4. Oluwadamilare说道:

    You have made some decent points there. I checked on the web for more information about the issue and found most individuals will go along with your views on this web site.

  5. Pretty! This was a really wonderful article. Thanks for supplying this info.

  6. check here说道:

    Just read this I was reading through some of your posts on this site and I think this internet site is rattling informative ! Keep on posting.

  7. online说道:

    I truly appreciate this post. I ave been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thx again

  8. will certainly digg it and in my opinion recommend to

  9. mca说道:

    There as certainly a lot to learn about this issue. I like all of the points you ave made.

  10. tui deo cheo nu说道:

    I think other web site proprietors should take this web site as an model, very clean and excellent user friendly style and design, let alone the content. You are an expert in this topic!

  11. to learn more说道:

    we came across a cool web-site which you might enjoy. Take a look should you want

  12. Really informative blog post.Really thank you! Fantastic.

  13. Looking forward to reading more. Great post.Much thanks again. Really Great.

  14. Major thankies for the article.Really looking forward to read more. Cool.

  15. her latest blog说道:

    Thanks so much for the article post.Much thanks again. Awesome.

  16. Nwokolo说道:

    This is a good tip particularly to those fresh to the blogosphere. Brief but very precise information Appreciate your sharing this one. A must read post!

  17. I value the article post.Much thanks again. Want more.

  18. Very good info. Lucky me I found your site by accident (stumbleupon). I ave saved as a favorite for later!

  19. Major thanks for the article post.Much thanks again. Much obliged.

  20. thiet ke website说道:

    Typewriter.. or.. UROPYOURETER. meaning аАа’аАТ‚аЂТ˜a collection of urine and pus in the ureter. a

  21. Wow, wonderful blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is great, as well as the content!

  22. this website说道:

    You, my pal, ROCK! I found exactly the info I already searched everywhere and simply could not find it. What an ideal web site.

  23. You have brought up a very superb details , thanks for the post.

  24. play说道:

    of these comments look like they are written by brain dead folks?

  25. women说道:

    the blog loads super quick for me on Internet explorer.

  26. When are you going to post again? You really entertain a lot of people!

  27. Investment tips说道:

    Thanks a lot for the article post.Really thank you! Great.

  28. Wonderful blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Thank you

  29. Really enjoyed this article post.Really thank you! Great.

  30. Wow, amazing blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is fantastic, let alone the content!

  31. Some really fantastic info , Gladiolus I detected this.

  32. try this说道:

    Wow, marvelous blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is wonderful, let alone the content!

  33. more说道:

    Just to let you know your site appears a little bit different on Safari on my laptop using Linux.

  34. kim thu set说道:

    Yes. It should get the job done. If it doesn at send us an email.

  35. this website说道:

    Its such as you learn my mind! You seem to grasp so much

  36. I’а†ve recently started a website, the information you offer on this web site has helped me greatly. Thanks for all of your time & work.

  37. School admission说道:

    Very nice post. I just stumbled upon your weblog and wished to say that I ave really enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again soon!

  38. There is clearly a bunch to identify about this. I consider you made various nice points in features also.

  39. click here说道:

    incredibly great submit, i really appreciate this internet internet site, carry on it

  40. Wow, awesome blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is great, let alone the content!. Thanks For Your article about sex.

  41. Major thankies for the blog.Thanks Again. Really Great.

  42. It!аЂа†s truly a nice and helpful piece of info. I am glad that you just shared this useful info with us. Please stay us informed like this. Thanks for sharing.

  43. It is hard to uncover knowledgeable individuals with this topic, nonetheless you look like there as extra that you are referring to! Thanks

  44. I truly appreciate this blog.Thanks Again. Awesome.

  45. marketing说道:

    I was recommended this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty. You are amazing! Thanks!

  46. Very informative blog article.Really looking forward to read more. Great.

  47. Really appreciate you sharing this article.Really thank you! Much obliged.

  48. tututorials说道:

    Muchos Gracias for your article post. Will read on

  49. resorts说道:

    Im grateful for the article.Much thanks again. Keep writing.

  50. There as certainly a great deal to learn about this issue. I love all of the points you have made.

  51. I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thx again..

  52. you ave got an amazing blog right here! would you like to make some invite posts on my weblog?

  53. Major thanks for the article post.Thanks Again. Want more.

  54. may ap trung ga说道:

    You are my inspiration , I possess few web logs and rarely run out from to post.

  55. state. This is the first time I frequented your web page and up to now?

  56. Winners说道:

    to assist with Search Engine Optimization? I am trying to get my blog to rank for some targeted keywords but I am not seeing very good results.

  57. Pretty nice post. I just found your web site and planned to say that i have really enjoyed browsing your blog posts

  58. I think you have noted some very interesting points , appreciate it for the post.

  59. This is really interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your wonderful post. Also, I ave shared your site in my social networks!

  60. It as really very complicated in this full of activity life to listen news on Television, therefore I simply use the web for that purpose, and take the newest information.

  61. share说道:

    Really appreciate you sharing this blog article.Really thank you! Keep writing.

  62. miller electric说道:

    I truly appreciate this article post.Thanks Again. Really Great.

  63. classified post说道:

    I truly appreciate this blog article.Much thanks again.

  64. go to see说道:

    That is a good tip especially to those fresh to the blogosphere. Brief but very accurate information Appreciate your sharing this one. A must read article!

  65. This unique blog is no doubt educating and also factual. I have picked many interesting things out of this amazing blog. I ad love to return every once in a while. Thanks a bunch!

  66. Thanks a lot for the blog post.Really thank you! Will read on

  67. Some truly interesting information, well written and broadly speaking user genial.

  68. cho thue xe may说道:

    Wow! This could be one particular of the most helpful blogs We have ever arrive across on this subject. Basically Magnificent. I am also an expert in this topic so I can understand your effort.

  69. Sites we recommend Nice blog here! Also your site loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my site loaded up as fast as yours lol

  70. Im grateful for the blog.Much thanks again. Want more.

  71. thung tam go说道:

    I truly appreciate this blog article.Really thank you! Cool.

  72. Way cool! Some extremely valid points! I appreciate you penning this article and the rest of the website is very good.

  73. This awesome blog is really awesome and informative. I have chosen a lot of handy advices out of this amazing blog. I ad love to go back again and again. Thanks!

  74. You ave made some good points there. I checked on the net to find out more about the issue and found most individuals will go along with your views on this web site.

  75. You can definitely see your enthusiasm in the work you write. The world hopes for more passionate writers like you who are not afraid to say how they believe. Always follow your heart.

  76. check here说道:

    It as nearly impossible to find educated people in this particular subject, but you seem like you know what you are talking about! Thanks

  77. Really enjoyed this article post.Much thanks again. Really Cool.

  78. It as hard to come by knowledgeable people on this topic, however, you seem like you know what you are talking about! Thanks

  79. Game Online说道:

    I’а†ve learn a few excellent stuff here. Definitely value bookmarking for revisiting. I surprise how so much attempt you put to create this type of great informative web site.

  80. It as difficult to find knowledgeable people for this subject, but you seem like you know what you are talking about! Thanks

  81. It as nearly impossible to find experienced people in this particular topic, however, you sound like you know what you are talking about! Thanks

  82. You ave made some decent points there. I checked on the net to learn more about the issue and found most individuals will go along with your views on this website.

  83. iHerb Thailand说道:

    What as up, just wanted to mention, I loved this article. It was funny. Keep on posting!

  84. My brother suggested I might like this blog. He was entirely right. This post actually made my day. You cann at imagine simply how much time I had spent for this info! Thanks!

  85. I will appreciate if you continue this in future.

  86. This awesome blog is definitely awesome additionally informative. I have found helluva interesting stuff out of it. I ad love to return again and again. Thanks a lot!

  87. There is certainly a lot to know about this subject. I like all of the points you made.

  88. Just what I was searching for, thankyou for putting up.

  89. may bo dam说道:

    Really informative post.Much thanks again. Great.

  90. You made some nice points there. I looked on the internet for the issue and found most persons will agree with your site.

  91. why not try here说道:

    Very good article post.Really looking forward to read more.

  92. Very nice blog post. I definitely appreciate this site. Thanks!

  93. this website说道:

    Very nice article and right to the point. I am not sure if this is really the best place to ask but do you guys have any ideea where to employ some professional writers? Thx

  94. ruou vang phap说道:

    Usually I do not read article on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been amazed me. Thanks, very nice article.

  95. Way cool! Some very valid points! I appreciate you writing this article plus the rest of the site is extremely good.

  96. Im thankful for the blog article.Really looking forward to read more. Keep writing.

  97. coupon2019说道:

    Wow! Thank you! I continuously wanted to write on my website something like that. Can I implement a portion of your post to my site?

  98. me suba说道:

    RLVZHS This is really interesting, You are a very skilled blogger. I ave joined your feed and look forward to seeking more of your wonderful post. Also, I have shared your site in my social networks!

  99. suba me说道:

    hzoQhM It as really a nice and helpful piece of info. I am glad that you shared this useful information with us. Please keep us informed like this. Thanks for sharing.

  100. arcadia realtor说道:

    This blog is definitely awesome and besides factual. I have picked many interesting things out of this amazing blog. I ad love to go back again and again. Thanks!

  101. This website was how do I say it? Relevant!! Finally I have found something which helped me. Appreciate it!

  102. Im thankful for the article post.Really looking forward to read more. Awesome.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>