javaxss默认大小(java xss参数)

今日新闻 2022年05月29日
本文导读目录:

JVM线程的栈在64位Linux操作系统上的默认大小是多少

不显式设置-Xss或-XX:ThreadStackSize时,在Linux x64上ThreadStackSize的默认值就是1024KB,给Java线程创建栈会用这个参数指定的大小。这是前一块代码的意思。

如果把-Xss或者-XX:ThreadStackSize设为0,就是使用“系统默认值”。而在Linux x64上HotSpot VM给Java栈定义的“系统默认”大小也是1MB。

所以这个条件下普通Java线程的默认栈大小怎样都是1MB。

java jvm内存可以设置多少

-Xmx Java Heap最大值,默认值为物理内存的1/4,最佳设值应该视物理内存大小及计算机内其他内存开销而定;

-Xms Java Heap初始值,Server端JVM最好将-Xms和-Xmx设为相同值,开发测试机JVM可以保留默认值;

-Xmn Java Heap Young区大小,不熟悉最好保留默认值; -Xss 每个线程的Stack大小,不熟悉最好保留默认值;

2

2. 如何分配JVM内存设置:

(1)当在命令提示符下启动并使用JVM时(只对当前运行的类Test生效): java -Xmx128m -Xms64m -Xmn32m -Xss16m Test (2)当在集成开发环境下(如eclipse)启动并使用JVM时:

a. 在eclipse根目录下打开eclipse.ini,默认内容为(这里设置的是运行当前开发工具的JVM内存分配): -vmargs -Xms40m -Xmx256m

-vmargs表示以下为虚拟机设置参数,可修改其中的参数值,也可添加-Xmn,-Xss,另外,eclipse.ini内还可以设置非堆内存,如:-XX:PermSize=56m,-XX:MaxPermSize=128m.

此处设置的参数值可以通过以下配置在开发工具的状态栏显示: 在eclipse根目录下创建文件options,文件内容为:org.eclipse.ui/perf/showHeapStatus=true

修改eclipse根目录下的eclipse.ini文件,在开头处添加如下内容: -debug options -vm javaw.exe

重新启动eclipse,就可以看到下方状态条多了JVM信息.

b. 打开eclipse-窗口-首选项-Java-已安装的JRE(对在当前开发环境中运行的java程序皆生效)

编辑当前使用的JRE,在缺省VM参数中输入:-Xmx128m -Xms64m -Xmn32m -Xss16m

c. 打开eclipse-运行-运行-Java应用程序(只对所设置的java类生效) 选定需设置内存分配的类-自变量,在VM自变量中输入:-Xmx128m -Xms64m

选定需设置内存分配的类-自变量,在VM自变量中输入:-Xmx128m -Xms64m -Xmn32m -Xss16m

注:如果在同一开发环境中同时进行了b和c设置,则b设置生效,c设置无效,如:

开发环境的设置为:-Xmx256m,而类Test的设置为:-Xmx128m -Xms64m,则运行Test时生效的设置为: -Xmx256m -Xms64m

(3)当在服务器环境下(如Tomcat)启动并使用JVM时(对当前服务器环境下所以Java程序生效): a. 设置环境变量: 变量名:CATALINA_OPTS

变量值:-Xmx128m -Xms64m -Xmn32m -Xss16m

3

b. 打开Tomcat根目录下的bin文件夹,编辑catalina.bat,将其中

的%CATALINA_OPTS%(共有四处)替换为:-Xmx128m -Xms64m -Xmn32m -Xss16m

如何设置Java虚拟机JVM启动内存参数

-Xmx Java Heap最大值,默认值为物理内存的1/4,最佳设值应该视物理内存大小及计算机内其他内存开销而定;

-Xms Java Heap初始值,Server端JVM最好将-Xms和-Xmx设为相同值,开发测试机JVM可以保留默认值;

-Xmn Java Heap Young区大小,不熟悉最好保留默认值;

-Xss 每个线程的Stack大小,不熟悉最好保留默认值;

2. 如何设置JVM内存分配:

(1)当在命令提示符下启动并使用JVM时(只对当前运行的类Test生效):

java -Xmx128m -Xms64m -Xmn32m -Xss16m Test

(2)当在集成开发环境下(如eclipse)启动并使用JVM时:

a. 在eclipse根目录下打开eclipse.ini,默认内容为(这里设置的是运行当前开发工具的JVM内存分配)

怎么查看Java(jvm)虚拟机的大小

由于java应用的允许依赖于JVM(虚拟机),相应的内存配置显然也需要JVM来提供的,准备地说是通过/bin/java.exe的启动命令参数来实现的。具体的配置项如下几种:-XmxJavaHeap最大值(默认值为物理内存的1/4)-XmsJavaHeap初始值-XmnJavaHeapYoung区大小-Xss每个线程的Stack大小拓展,以下是几种使用示例:1、命令下启动应用并配置内存:java-Xmx128m-Xms64mTest2、eclipse内存配置:-vmargs-Xms40m-Xmx512m的配置信息,请自行搜索“jvm内存”。

java xms 怎么设置大小

在一些规模稍大的应用中,Java虚拟机(JVM)的内存设置尤为重要,想在项目中取得好的效率,GC(垃圾回收)的设置是第一步。

PermGen space:全称是Permanent Generation space.就是说是永久保存的区域,用于存放Class和Meta信息,Class在被Load的时候被放入该区域Heap space:存放Instance。

GC(Garbage Collection)应该不会对PermGen space进行清理,所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen space错误

Java Heap分为3个区

1.Young

2.Old

3.Permanent

Young保存刚实例化的对象。当该区被填满时,GC会将对象移到Old区。Permanent区则负责保存反射对象,本文不讨论该区。

JVM的Heap分配可以使用-X参数设定,

-Xms

初始Heap大小

-Xmx

java heap最大值

-Xmn

young generation的heap大小

JVM有2个GC线程

第一个线程负责回收Heap的Young区

第二个线程在Heap不足时,遍历Heap,将Young 区升级为Older区

Older区的大小等于-Xmx减去-Xmn,不能将-Xms的值设的过大,因为第二个线程被迫运行会降低JVM的性能。

为什么一些程序频繁发生GC?

有如下原因:

1.程序内调用了System.gc()或Runtime.gc()。

2.一些中间件软件调用自己的GC方法,此时需要设置参数禁止这些GC。

3.Java的Heap太小,一般默认的Heap值都很小。

4.频繁实例化对象,Release对象 此时尽量保存并重用对象,例如使用StringBuffer()和String()。

如果你发现每次GC后,Heap的剩余空间会是总空间的50%,这表示你的Heap处于健康状态,许多Server端的Java程序每次GC后最好能有65%的剩余空间

经验之谈:

1.Server端JVM最好将-Xms和-Xmx设为相同值。为了优化GC,最好让-Xmn值约等于-Xmx的1/3。

2.一个GUI程序最好是每10到20秒间运行一次GC,每次在半秒之内完成。

注意:

1.增加Heap的大小虽然会降低GC的频率,但也增加了每次GC的时间。并且GC运行时,所有的用户线程将暂停,也就是GC期间,Java应用程序不做任何工作。

2.Heap大小并不决定进程的内存使用量。进程的内存使用量要大于-Xmx定义的值,因为Java为其他任务分配内存,例如每个线程的Stack等。

Stack的设定

每个线程都有他自己的Stack。

-Xss

每个线程的Stack大小

Stack的大小限制着线程的数量。如果Stack过大就好导致内存溢漏。-Xss参数决定Stack大小,例如-Xss1024K。如果Stack太小,也会导致Stack溢漏。

硬件环境

硬件环境也影响GC的效率,例如机器的种类,内存,swap空间,和CPU的数量。

如果你的程序需要频繁创建很多transient对象,会导致JVM频繁GC。这种情况你可以增加机器的内存,来减少Swap空间的使用。

4种GC

1、第一种为单线程GC,也是默认的GC,该GC适用于单CPU机器。

2、第二种为Throughput GC,是多线程的GC,适用于多CPU,使用大量线程的程序。第二种GC与第一种GC相似,不同在于GC在收集Young区是多线程的,但在Old区和第一种一样,仍然采用单线程。-XX:+UseParallelGC参数启动该GC。

3、第三种为Concurrent Low Pause GC,类似于第一种,适用于多CPU,并要求缩短因GC造成程序停滞的时间。这种GC可以在Old区的回收同时,运行应用程序。-XX:+UseConcMarkSweepGC参数启动该GC。

4、第四种为Incremental Low Pause GC,适用于要求缩短因GC造成程序停滞的时间。这种GC可以在Young区回收的同时,回收一部分Old区对象。-Xincgc参数启动该GC。

单文件的JVM内存进行设置

默认的java虚拟机的大小比较小,在对大数据进行处理时java就会报错:java.lang.OutOfMemoryError。

设置jvm内存的方法,对于单独的.class,可以用下面的方法对Test运行时的jvm内存进行设置。

java -Xms64m -Xmx256m Test

-Xms是设置内存初始化的大小

-Xmx是设置最大能够使用内存的大小(最好不要超过物理内存大小)

tomcat启动jvm内存设置

Linux:

在/usr/local/apache-tomcat-5.5.23/bin目录下的catalina.sh添加:JAVA_OPTS='-Xms512m -Xmx1024m'要加“m”说明是MB,否则就是KB了,在启动tomcat时会报内存不足。

-Xms:初始值

-Xmx:最大值

-Xmn:最小值Windows

在catalina.bat最前面加入

set JAVA_OPTS=-Xms128m -Xmx350m 如果用startup.bat启动tomcat,OK设置生效.够成功的分配200M内存.但是如果不是执行startup.bat启动tomcat而是利用windows的系统服务启动tomcat服务,上面的设置就不生效了,就是说set JAVA_OPTS=-Xms128m -Xmx350m 没起作用.上面分配200M内存就OOM了..windows服务执行的是bin\tomcat.exe.他读取注册表中的值,而不是catalina.bat的设置.解决办法:

修改注册表HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat Service Manager\Tomcat5\Parameters\JavaOptions

怎么把Java运行时的虚拟机参数的栈大小调到256K以上

-Xss256K: 设置每个线程的运行时栈的大小为 256K。

相关参数:

-Xmx,设置JVM最大内存;比如 -Xmx512M: 设置JVM最大内存为512M;

-Xms,设置JVM最小内存;比如 -Xms512M: 设置JVM最小内存为512M;

-Xmn,设置JVM年轻代内存;比如 -Xmn1G:设置年轻代内存为 1 G。

关键词: javaxss默认大小
我来说两句
黑客技术 3年前 (2022-05-30) | 回复
32m -Xss16m c. 打开eclipse-运行-运行-Java应用程序(只对所设置的java类生效) 选定需设置内存分配的类-自变量,在VM
黑客技术 3年前 (2022-05-29) | 回复
后,Heap的剩余空间会是总空间的50%,这表示你的Heap处于健康状态,许多Server端的Java程序每次GC后最好能有65%的剩余空间经验之谈:1.Server端JVM最好将-Xms和-Xmx设为相同值。为了优化GC,最好让-Xmn值约等于-Xmx的1/3。2.一个GUI程序最好是每10到20
黑客技术 3年前 (2022-05-29) | 回复
Xss 每个线程的Stack大小Stack的大小限制着线程的数量。如果Stack过大就好导致内存溢漏。-Xss参数决定Stack大小,例如-Xss1024K。如果
黑客技术 3年前 (2022-05-29) | 回复
(只对当前运行的类Test生效):java -Xmx128m -Xms64m -Xmn32m -Xss16m Test(2)当在集成开发环境下(如eclipse)启动并使用J
黑客技术 3年前 (2022-05-29) | 回复
6m,而类Test的设置为:-Xmx128m -Xms64m,则运行Test时生效的设置为: -Xmx256m -Xms64m (3)当在服务器环
yeezyoutlet 12个月前 (11-27) | 回复
I am only commenting to let you be aware of of the magnificent discovery my cousin's girl enjoyed browsing your webblog. She picked up lots of things, most notably what it's like to have an excellent giving character to have a number of people smoothly know several extremely tough subject matter. You actually exceeded visitors' desires. Thank you for imparting such important, healthy, revealing and even cool guidance on that topic to Ethel.
nikesb 11个月前 (12-14) | 回复
I simply needed to say thanks all over again. I do not know the things that I might have followed without the actual tips and hints shared by you regarding such situation. It had become a very troublesome issue in my circumstances, but being able to view a professional approach you managed that made me to cry over happiness. Now i am happy for the help as well as trust you know what a great job you are always putting in educating other individuals by way of your web site. I'm certain you've never come across all of us.
kd14 11个月前 (12-28) | 回复
I precisely wanted to thank you so much once again. I do not know what I might have achieved in the absence of these tips and hints revealed by you regarding my theme. It truly was a fearsome setting for me personally, nevertheless taking a look at the very professional way you processed it forced me to leap with happiness. Now i'm thankful for the help and then hope that you know what an amazing job you have been accomplishing teaching people today by way of your webpage. Most probably you have never encountered any of us.
jordan13 11个月前 (12-29) | 回复
I needed to write you this bit of observation to help thank you so much again with your magnificent opinions you've shown on this website. It is certainly unbelievably generous of people like you to present unhampered what exactly some people would have supplied for an ebook to end up making some cash for their own end, most importantly seeing that you might have tried it in case you decided. Those suggestions likewise served to become a easy way to fully grasp that other people online have a similar keenness similar to my very own to understand whole lot more in respect of this matter. I think there are a lot more pleasant occasions in the future for those who read your site.
offwhiteoutlet 11个月前 (12-30) | 回复
I'm writing to make you understand what a fine discovery my princess obtained checking your webblog. She came to understand some issues, including what it's like to have a great helping spirit to have the mediocre ones with no trouble master specific impossible issues. You actually exceeded readers' expectations. Many thanks for churning out those invaluable, safe, revealing not to mention fun thoughts on your topic to Mary.
supremeclothing 11个月前 (01-01) | 回复
Thanks for your entire hard work on this blog. My daughter takes pleasure in going through investigations and it's really simple to grasp why. All of us learn all of the lively tactic you give vital information via your web site and even strongly encourage participation from people on the concept and our own daughter is without a doubt understanding a lot of things. Enjoy the remaining portion of the year. You are always carrying out a first class job.
birkinbag 11个月前 (01-02) | 回复
I am glad for commenting to make you be aware of of the excellent discovery my cousin's princess undergone reading through your web site. She learned plenty of things, with the inclusion of how it is like to have an excellent coaching heart to get the mediocre ones clearly thoroughly grasp some complex matters. You undoubtedly surpassed our own expected results. I appreciate you for supplying the important, safe, revealing and even cool guidance on that topic to Jane.
stephencurryshoes 11个月前 (01-04) | 回复
My spouse and i were very satisfied that Jordan could carry out his basic research from your precious recommendations he discovered from your own web page. It is now and again perplexing to simply be giving for free things which often some others might have been making money from. And we also realize we need the writer to appreciate because of that. The illustrations you made, the straightforward website menu, the friendships you can assist to create - it's got many powerful, and it is aiding our son in addition to the family know that this issue is excellent, and that's exceedingly pressing. Thanks for the whole lot!
goyardbags 11个月前 (01-05) | 回复
I want to express my appreciation for your generosity supporting folks that absolutely need help on this particular matter. Your very own dedication to passing the solution all through has been really productive and have always empowered men and women much like me to attain their targets. Your personal insightful tutorial means a great deal to me and further more to my office workers. With thanks; from all of us.
bapehoodie 11个月前 (01-08) | 回复
I enjoy you because of all of the effort on this web site. Ellie delights in engaging in investigation and it is easy to see why. My spouse and i hear all relating to the compelling form you make simple guidance through this blog and in addition welcome response from website visitors about this subject and my princess is in fact starting to learn a great deal. Enjoy the remaining portion of the year. You are conducting a glorious job.
hermesoutlet 11个月前 (01-09) | 回复
I precisely had to appreciate you yet again. I am not sure the things I could possibly have implemented in the absence of the entire tips and hints provided by you directly on such a theme. It actually was a very hard issue in my view, however , taking a look at the very professional avenue you managed that forced me to jump over gladness. I'm just grateful for your guidance and as well , hope you really know what an amazing job you were undertaking teaching other individuals thru your web site. I know that you've never come across any of us.
jordan 11个月前 (01-10) | 回复
I precisely desired to appreciate you once again. I'm not certain the things that I could possibly have tried in the absence of the entire points documented by you directly on such problem. It seemed to be a very daunting dilemma for me, but being able to see this specialised avenue you solved the issue made me to jump over delight. I am just happier for the advice and hope that you realize what a great job that you are carrying out educating men and women using your blog. Probably you've never got to know all of us.
nikekyrie7 11个月前 (01-11) | 回复
Thanks for your whole effort on this web page. My mother take interest in doing investigations and it's really easy to see why. We notice all concerning the powerful method you produce precious tactics via this web blog and improve response from people on that concern plus our own girl is certainly being taught a great deal. Enjoy the rest of the year. You are always carrying out a useful job.
offwhitejordan1 10个月前 (01-13) | 回复
I wish to express my affection for your kindness in support of persons that really need help on that question. Your very own dedication to getting the solution all around appeared to be amazingly good and has without exception helped women just like me to realize their ambitions. Your new insightful recommendations indicates much a person like me and even more to my colleagues. Thanks a ton; from everyone of us.
offwhiteoutlet 10个月前 (01-14) | 回复
I want to express appreciation to the writer for bailing me out of this type of trouble. Because of surfing around through the the web and coming across proposals which are not beneficial, I believed my entire life was well over. Living devoid of the approaches to the problems you have solved through your good write-up is a crucial case, as well as ones which may have badly affected my career if I hadn't encountered your web page. Your natural talent and kindness in playing with the whole lot was very helpful. I don't know what I would've done if I hadn't come upon such a step like this. I'm able to at this time relish my future. Thanks a lot so much for your skilled and effective help. I won't be reluctant to endorse your web blog to anyone who would like tips on this issue.
bapesta 10个月前 (01-16) | 回复
I just wanted to type a small remark so as to say thanks to you for those awesome recommendations you are posting here. My considerable internet lookup has at the end been recognized with reliable content to share with my pals. I 'd express that most of us readers actually are very blessed to live in a decent community with so many lovely individuals with helpful strategies. I feel rather fortunate to have used your entire website page and look forward to really more brilliant moments reading here. Thank you again for a lot of things.
goyardbags 10个月前 (01-17) | 回复
I wanted to put you that little word to say thanks a lot as before with the magnificent techniques you have shown on this website. This is really particularly open-handed of you to make without restraint all a lot of folks would have offered for sale as an ebook to generate some bucks for their own end, chiefly now that you could have tried it if you wanted. The ideas in addition acted to be a great way to realize that many people have the same eagerness similar to mine to see a whole lot more regarding this issue. I'm certain there are several more pleasurable occasions in the future for those who read carefully your blog.
kd15 10个月前 (01-19) | 回复
I want to show some thanks to this writer just for bailing me out of this setting. As a result of checking throughout the the net and seeing ways which were not beneficial, I assumed my life was well over. Living minus the strategies to the issues you've sorted out through the blog post is a serious case, and the kind that could have in a wrong way damaged my career if I had not noticed the blog. Your main capability and kindness in dealing with a lot of stuff was important. I'm not sure what I would've done if I had not come upon such a subject like this. I'm able to at this time look forward to my future. Thanks very much for your professional and sensible guide. I will not be reluctant to suggest your web page to any person who will need support about this issue.
bape 10个月前 (01-20) | 回复
My spouse and i have been quite delighted Louis managed to finish up his homework because of the precious recommendations he made through the site. It's not at all simplistic just to happen to be making a gift of techniques others could have been selling. And now we acknowledge we've got the blog owner to thank because of that. All of the illustrations you made, the simple blog menu, the friendships you can assist to instill - it is everything spectacular, and it is assisting our son in addition to the family imagine that that theme is awesome, and that is unbelievably serious. Many thanks for the whole thing!
fearofgodclothing 10个月前 (01-21) | 回复
I enjoy you because of every one of your hard work on this web page. Kim really loves managing internet research and it is obvious why. Many of us learn all about the compelling tactic you deliver advantageous things by means of the web blog and even boost response from visitors about this matter plus my child is certainly discovering a lot of things. Take pleasure in the remaining portion of the new year. You're doing a pretty cool job.
goldengooseplatformsneakers 10个月前 (01-22) | 回复
I抦 impressed, I must say. Really not often do I encounter a blog that抯 both educative and entertaining, and let me let you know, you've hit the nail on the head. Your concept is excellent; the difficulty is something that not sufficient individuals are talking intelligently about. I am very completely satisfied that I stumbled throughout this in my search for something regarding this.
kyrie7shoes 10个月前 (01-23) | 回复
I needed to draft you a very little remark so as to thank you very much yet again considering the nice guidelines you've shown on this page. It has been so tremendously generous of people like you to allow without restraint all that many people might have advertised for an electronic book to generate some bucks for themselves, and in particular now that you might have done it in the event you desired. The tricks in addition worked to provide a fantastic way to be aware that most people have the identical passion really like my personal own to realize lots more with respect to this matter. I believe there are a lot more enjoyable opportunities up front for individuals who start reading your blog post.
fearofgodessentialshoodie 10个月前 (01-24) | 回复
I precisely desired to say thanks yet again. I do not know what I might have made to happen in the absence of these basics documented by you concerning that question. It had been the depressing condition in my position, nevertheless witnessing a new skilled fashion you handled it took me to jump over happiness. I am just grateful for the advice and as well , trust you comprehend what a great job that you're carrying out training people today via your web site. I am sure you have never met any of us.