如何为tomcat应用程序增加Java堆空间 [英] How to increase Java heap space for a tomcat app

查看:122
本文介绍了如何为tomcat应用程序增加Java堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多问题要问这个或类似的问题。

There are lots of questions that ask this or a similar question.

他们都给出了必须执行的命令,我不明白的是哪里我写这个命令。我想永久增加我的tomcat应用程序的堆空间。

They all give the command that has to be executed, what I don't understand is where do I write this command. I want to permanently increase the heap space for my tomcat apps.

我读过这个页面 http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html 它表示在Tomcat部分下

I read this page http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html and it says under the Tomcat section


停止Tomcat服务器,设置环境变量CATALINA_OPTS,然后重新启动Tomcat。查看文件tomcat-install / bin / catalina.sh或catalina.bat以了解如何使用此变量。例如,

Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,

设置CATALINA_OPTS = -Xms512m -Xmx512m(Windows,没有围绕值)

export CATALINA_OPTS = - Xms512m -Xmx512m (ksh / bash,围绕价值)

setenv CATALINA_OPTS-Xms512m -Xmx512m(tcsh / csh,围绕值)

set CATALINA_OPTS=-Xms512m -Xmx512m (Windows, no "" around the value)
export CATALINA_OPTS="-Xms512m -Xmx512m" (ksh/bash, "" around the value)
setenv CATALINA_OPTS "-Xms512m -Xmx512m" (tcsh/csh, "" around the value)

所以我更换了行


设置CATALINA_OPTS =

set CATALINA_OPTS=

with


设置CATALINA_OPTS = -Xms512m -Xmx512m

set CATALINA_OPTS=-Xms512m -Xmx512m

但我仍然得到错误。


javax.servlet。 ServletException:Servlet执行引发异常

javax.servlet.ServletException: Servlet execution threw an exception

根本原因

java.lang.OutOfMemoryError:Java堆空间
java.lang.reflect.Array.multiNewArray(Native Method)
java.lang.reflect.Array.newInstance(Array.java:90)
nom.tam.util.ArrayFuncs.newInstance(ArrayFuncs) .java:1028)
nom.tam.fi ts.ImageData.read(ImageData.java:259)
nom.tam.fits.Fits.readHDU(Fits.java:573)
controller.UploadServlet.retreiveFITSFileFields(UploadServlet.java:206)
controller.ScanServerFiles.doPost(ScanServerFiles.java:39)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet。 java:717)

java.lang.OutOfMemoryError: Java heap space java.lang.reflect.Array.multiNewArray(Native Method) java.lang.reflect.Array.newInstance(Array.java:90) nom.tam.util.ArrayFuncs.newInstance(ArrayFuncs.java:1028) nom.tam.fits.ImageData.read(ImageData.java:259) nom.tam.fits.Fits.readHDU(Fits.java:573) controller.UploadServlet.retreiveFITSFileFields(UploadServlet.java:206) controller.ScanServerFiles.doPost(ScanServerFiles.java:39) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


推荐答案

您的更改可能正常。您的应用程序是否需要大量内存 - 堆栈跟踪显示一些与图像相关的功能。

Your change may well be working. Does your application need a lot of memory - the stack trace shows some Image related features.

我猜测错误要么立即发生,要么是大文件,或者在几次请求之后发生。

I'm guessing that the error either happens right away, with a large file, or happens later after several requests.

如果错误立即发生,那么你可以进一步增加内存,或调查找​​出为什么一个文件需要这么多内存。

If the error happens right away, then you can increase memory still further, or investigate find out why so much memory is needed for one file.

如果在多次请求之后发生错误,那么您可能会发生内存泄漏 - 垃圾收集器不会回收对象。使用 JProfiler 等工具
可以帮助您监控多少您的VM正在使用内存,可以帮助您查看正在使用该内存的内容以及垃圾收集器未回收对象的原因。

If the error happens after several requests, then you could have a memory leak - where objects are not being reclaimed by the garbage collector. Using a tool like JProfiler can help you monitor how much memory is being used by your VM and can help you see what is using that memory and why objects are not being reclaimed by the garbage collector.

这篇关于如何为tomcat应用程序增加Java堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆