java tomcat中的Java堆空间错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11446469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Heap Space Error in tomcat
提问by Vijay
I am using Tomcat 7.0.28. I have deployed a war file. In this war file there is a server like structure where we can upload the files.
我正在使用 Tomcat 7.0.28。我已经部署了一个War文件。在这个War文件中有一个类似服务器的结构,我们可以在其中上传文件。
Now when i access that web page it is working, but when i try to upload the large files it is showing error of JAVA Heap Space.
现在,当我访问该网页时它正在工作,但是当我尝试上传大文件时,它显示 JAVA 堆空间错误。
How can i solve it?
我该如何解决?
回答by Miquel
You are probably trying to put the whole file in memory. Your first shot should be to change the -Xmx parameter at the Tomcat JVM startup options to give it more memor. Aside from that, you'll have to read the file one chunk at a time, and write it on the hard drive, so as to free the memory.
您可能正在尝试将整个文件放入内存中。您的第一个尝试应该是更改 Tomcat JVM 启动选项中的 -Xmx 参数以提供更多记忆。除此之外,您必须一次读取一个文件块,并将其写入硬盘驱动器,以释放内存。
回答by amicngh
You can increase HeapSize
in tomcat using below command .
您可以HeapSize
使用以下命令增加tomcat。
Linux :Open Catalina.shfile placed in the "bin" directory. You have to apply the changes to this line
Linux:打开放置在“bin”目录中的Catalina.sh文件。您必须将更改应用于此行
CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m "
Windows:
视窗:
Open the "Catalina.bat" file placed in the "bin" directory
打开放置在“bin”目录下的“ Catalina.bat”文件
set CATALINA_OPTS=-server -Xms256m -Xmx1024m
Restart the tomcat after above change.
以上更改后重新启动tomcat。