java虚拟机内存不足, “Could notcreatetheJava Virtual
Machine”问题解决方案
大概原因就是java堆内存不足以运行JVM需要增加内存。
网上搜索此问题大部分都是针对某个程序进行修改JVM内存的解决方法 比如ecl ipse,等。试问若是其他程序出现问题了呢
现在给出一个全局的java虚拟机修改内存的方法。在WINXP,WIN 7,WIN8都可以。 解决方案增加一个系统环境变量
变量名 _JAVA_OPTIONS
变量值 -Xmx512M
保存后就OK! !
下面给出关于java堆内存的一个介绍这是一个英文网页的翻译过来的。
关于java堆内存
Java-Xmxis theconfiguration parametertocontrol the amountof memoryJava useson asystem.Basical lythesesettingsaretheretocontrol the Heap memorysizeof Java.Therearetwosettings relatedtoJava heap memory:
?
?-Xmxtoset themaximum heapmemorysize-Xmstoset theminimum heapmemorysize
Tipstoset theJava heap memorysize
ManagingtheJava heap memorysizeforaserver isverycrucial asthe whole performancedepends on this memorysize,off coursethere areother factors which affects the performance.So let’s see howyou can set these parameters tocontrol theJava heap memorysize.
Donot set -Xmxtotoosmal lvalue
If youset -Xmxtoosmal l foryourserverthenyourappl ication maynot work properlyandyou maygetOutof memoryexception.So neverset this too smal las this is themaximumamountof memoryyouareal locatingforJava anditcannotuti l izememorybeyondthesetvalue.
It isalwaysadvisabletoset -Xmxtoa highervalueif you haveenough memoryspaceavai lableonyourserver.Ontheotherhandif youset -Xmx valuetoahighervalueyourother resourceswi l l notbeabletoperformwel las you have already reserved some of your memoryforJava.So beforesetting themaximum heapsizememoryjustcheckhowmuch memoryis free.Todo so, stopyourappl ication serverand checkthefreememoryand accordingly you canset themaximum memorysize. Forexampleif you have512M free memorythenyou can set heap memoryto300M safelyi .e. -Xmx300m.
Set -Xmstoasmal lvalue
If youset -Xms tohighervalueyou might runoutof memory.Soalways trytokeepit toasmal lvaluel ike-Xms16m. Intomcatwhenyou restart the
server it starts aJava processandthat process takes thesame-Xmsas the defaultvalueforthetomcatand if it is higheryou maygetoutof memory.
Nowlet’s seehowtosetjava heap memory in different servers.
Howtosetjava heapsizeinTomcat
Toset thejava heapsizeintomcatyou needtoedit thecatal ina.sh(On Linux)orcatal ina.bat (OnWindows) fi le.Youcanfindthesefi les insidethebin directory of tomcat.Open theappropriatefi le and search forCATALINA_OPTS andset thevalueas shownbelow,youcan changethemaxandminvalueto whateveryou want.set CATALINA_OPTS=-Xms64m-Xmx512m
export CATALINA_OPTS=”-Xms64m-Xmx512m”setenv CATALINA_OPTS“-Xms64m-Xmx512m”
大概翻译如下
Java-xmx配置参数控制Java系统上使用的内存量。 基本上这些设置有控制Java堆内存的大小。 有两种设置相关的Java堆内存:
?
?-xmx设置最大的堆内存的大小xms设置最小堆内存大小建议设置Java堆内存大小
管理服务器的Java堆内存大小是非常重要的整个性能取决于这个内存大小,当然还有其他因素影响性能。 所以让我们来看看你可以设置这些参数来控制Java堆内存大小。 不设置-xmx太小价值
如果你为你的服务器设置-xmx太小,那么您的应用程序可能无法正常
工作,你可能会得到内存不足异常。 所以不要设置过小,因为这是你们的最大内存分配为Java和它不能利用内存超出设定的值。
它总是明智的-xmx较高的值,如果你有足够的内存空间可用的服务器上。 另一方面如果你-xmx值设置为较高的值其他资源将无法执行以及你已经保留你的一些Java内存。 所以设置最大堆大小的内存之前就检查多少内存是免费的。 为此,停止应用服务器并检查空闲内存,因此您可以设置最大的内存大小。 例如,如果你有512的空闲内存,那么你可以设置堆内存300安全即-Xmx300m。xms设置为一个较小的值
如果你设置xms更高的值可能会耗尽内存。 所以总是试图保持它像-Xms16m一个较小的值。 在tomcat中当你重新启动服务器,启动一个Java 进程,过程需要相同的xms tomcat的默认值,如果它是更高的你可能会失去记忆。
现在让我们看看如何在不同的服务器上设置java堆内存。
如何设置Tomcatjava堆大小
设置java堆大小在tomcat中您需要编辑catal ina.sh(在Linux上)或catal ina。 蝙蝠(在Windows上)文件。 你可以找到这些文件在tomcat的bin目录。打开相应的文件和搜索CATALI NA_OPTS和设置值如下所示,你可以改变任何你想要的最大和最小值。 设置CATALINA_OPTS=-Xms64m -Xmx512m
出口CATALINA_OPTS=" -Xms64m-Xmx512m”setenv CATALINA_OPTS”-Xms64m-Xmx512m”
raksmart作为一家老牌美国机房总是被很多人问到raksmart香港服务器怎么样、raksmart好不好?其实,这也好理解。香港服务器离大陆最近、理论上是不需要备案的服务器里面速度最快的,被过多关注也就在情理之中了。本着为大家趟雷就是本站的光荣这一理念,拿了一台raksmart的香港独立服务器,简单做个测评,分享下实测的数据,仅供参考!官方网站:https://www.raksmart.com...
Sharktech最近洛杉矶和丹佛低价配置大部分都无货了,只有荷兰机房还有少量库存,商家又提供了两款洛杉矶特价独立服务器,价格不错,CPU/内存/硬盘都是高配,1-10Gbps带宽不限流量最低129美元/月起。鲨鱼机房(Sharktech)我们也叫它SK机房,是一家成立于2003年的老牌国外主机商,提供的产品包括独立服务器租用、VPS主机等,自营机房在美国洛杉矶、丹佛、芝加哥和荷兰阿姆斯特丹等,主...
justhost怎么样?justhost是一家俄罗斯主机商,2006年成立,提供各种主机服务,vps基于kvm,有HDD和SSD硬盘两种,特色是200Mbps不限流量(之前是100Mbps,现在升级为200Mbps)。下面是HDD硬盘的KVM VPS,性价比最高,此外还有SSD硬盘的KVM VPS,价格略高。支持Paypal付款。国内建议选择新西伯利亚或者莫斯科DataLine。支持Paypal付...