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”
Hostodo 算是比较小众的海外主机商,这次九月份开学季有提供促销活动。不过如果我们有熟悉的朋友应该知道,这个服务商家也是比较时间久的,而且商家推进活动比较稳,每个月都有部分活动。目前有提供机房可选斯波坎、拉斯维加斯和迈阿密。从机房的地理位置和实际的速度,中文业务速度应该不是优化直连的,但是有需要海外业务的话一般有人选择。以前一直也持有他们家的年付12美元的机器,后来用不到就取消未续约。第一、开...
Spinservers是Majestic Hosting Solutions,LLC旗下站点,主营美国独立服务器租用和Hybrid Dedicated等,数据中心位于美国德克萨斯州达拉斯和加利福尼亚圣何塞机房。TheServerStore.com,自 1994 年以来,它是一家成熟的企业 IT 设备供应商,专门从事二手服务器和工作站业务,在德克萨斯州拥有 40,000 平方英尺的仓库,库存中始终有...
丽萨主机怎么样?丽萨主机,团队于2017年成立。成立之初主要做的是 CDN 和域名等相关业务。最近开辟新领域,新增了独立服务器出租、VPS 等业务,为了保证业务质量从一开始就选择了中美之间的 CN2 GIA 国际精品网络,三网回程 CN2 GIA,电信去程 CN2 GIA + BGP 直连智能路由,联通移动去程直连,原生IP。适合对网络要求较高的用户,同时价格也比较亲民。点击进入:丽萨主机官方网站...