系統(tǒng)大全為您提供不可行的方法?最初我直接修改catalina.sh,將JAVA_OPTS變量加上了?-server-xms1G-Xmx1G-XX:+UserG1GC最初看起來沒啥問題,但是當(dāng)服務(wù)器運(yùn)行幾天后,發(fā)現(xiàn)執(zhí)行shutdown.sh無法關(guān)閉tomcat,錯(cuò)誤信息如下:?#root@iZ94hjppdqzZ:~/projects/taolijie#caths_err_pid5519.log?#ThereisinsufficientmemoryfortheJavaRuntimeEnvironmenttocontinue.#Nativememoryallocation(mmap)Failedtomap1073741824bytesforcommittingreservedmemory.#Possiblereasons:#?ThesystemisoutofphysicalRAMorswapspace#?In32bitmode,theprocesssizelimitwashit#Possiblesolutions:#?Reducememoryloadonthesystem#?Increasephysicalmemoryorswapspace#?Checkifswapbackingstoreisfull#?Use64bitJavaona64bitOS#?DecreaseJavaheapsize(-Xmx/-xms)#?DecreasenumberofJavathreads#?DecreaseJavathreadstacksizes(-Xss)#?Setlargercodecachewith-XX:ReservedCodeCacheSize=#Thisoutputfilemaybetruncatedorincomplete.##?OutofMemoryError(os_linux.cpp:2673),pid=5519,tid=3061726064##JREversion:?(8.0_45-b14)(build)#JavaVM:JavaHotSpot(TM)ServerVM(25.45-b02mixedmodelinux-x86)#Failedtowritecoredump.Coredumpshavebeendisabled.Toenablecoredumping,try"ulimit-cunlimited"beforestartingJavaagain#關(guān)閉個(gè)tomcat要請(qǐng)求1G的內(nèi)存,當(dāng)時(shí)服務(wù)器就剩下200M內(nèi)存,所以O(shè)utOfMemory了。查看shutdown.sh,發(fā)現(xiàn)它其實(shí)還是調(diào)用了catalina.sh,只是傳入了一個(gè)stop參數(shù)。而catalina.sh是執(zhí)行了?org.apache.catalina.startup.Bootstrapstop來向tomcat發(fā)送關(guān)閉信息的。由于上面我們?cè)O(shè)置了JAVA_OPTS使用1G的堆,因此執(zhí)行該類時(shí)JVM會(huì)向系統(tǒng)申請(qǐng)1G多的內(nèi)存,直接導(dǎo)致OutOfMemory。?可行的方法?在catalina.sh的第二行添加:?CATALINA_OPTS="$CATALINA_OPTS-server-xms1G-Xmx1G-XX:+UseG1GC"這些VM參數(shù)就會(huì)只應(yīng)用到catalina而不是所有Tomcat進(jìn)程。???以上就是系統(tǒng)大全給大家介紹的如何使的方法都有一定的了解了吧,好了,如果大家還想了解更多的資訊,那就趕緊點(diǎn)擊系統(tǒng)大全官網(wǎng)吧。??本文來自系統(tǒng)大全http:///如需轉(zhuǎn)載請(qǐng)注明!