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”
云基yunbase怎么样?云基成立于2020年,目前主要提供高防海内外独立服务器,欢迎各类追求稳定和高防优质线路的用户。业务可选:洛杉矶CN2-GIA+高防(默认500G高防)、洛杉矶CN2-GIA(默认带50Gbps防御)、香港CN2-GIA高防(双向CN2GIA专线,突发带宽支持,15G-20G DDoS防御,无视CC)。目前,美国洛杉矶CN2-GIA高防独立服务器,8核16G,最高500G ...
欧路云怎么样?欧路云主要运行弹性云服务器,可自由定制配置,可选加拿大的480G超高防系列,也可以选择美国(200G高防)系列,也有速度直逼内地的香港CN2系列。所有配置都可以在下单的时候自行根据项目 需求来定制自由升级降级 (降级按天数配置费用 退款回预存款)。2021年7月14日美国 CERA 弹性云服务器 上新 联通CUVIP 线路!8折特惠中!点击进入:欧路云官方网站地址付款方式:PayPa...
一、麻花云官网点击直达麻花云官方网站二、活动方案优惠码:专属优惠码:F1B07B 享受85折优惠。点击访问活动链接最新活动 :五一狂欢 惠战到底 香港云主机 1.9折起香港特价体验云主机CN2 云服务器最新上线KVM架构,,默认40G SSD,+10G自带一个IPv4,免费10Gbps防御,CPU内存带宽价格购买1核1G1M19元首月链接2核2G 2M92元/3个月链接2核4G3M112元/3个月...