如何增加 jBoss 服务器的堆大小 [英] How to increase heap size for jBoss server

查看:30
本文介绍了如何增加 jBoss 服务器的堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一个上传文件方案.当我尝试上传大文件时,它给了我 OutOfMemory 错误.该错误与 Java 堆大小有关.

I have an upload files scenario in my project. When I'm trying to upload the large files it's giving me an OutOfMemory error. That error is related to Java heap size.

如何增加 Java 中的堆大小,为此我需要更改哪个文件?我正在使用 jboss 5.1 服务器来运行我的应用程序.

How can you increase the heap size in Java and which file do I need to alter for this? I'm using jboss 5.1 server for running my application.

推荐答案

您可以按照通常的方式将其设置为 JVM 参数,例如-Xms1024m -Xmx2048m 最小堆为 1GB,最大堆为 2GB.JBoss 将使用 JAVA_OPTS 环境变量来包含额外的 JVM 参数,您可以在 /bin/run.conf.bat 文件中指定它:

You can set it as JVM arguments the usual way, e.g. -Xms1024m -Xmx2048m for a minimum heap of 1GB and maximum heap of 2GB. JBoss will use the JAVA_OPTS environment variable to include additional JVM arguments, you could specify it in the /bin/run.conf.bat file:

set "JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx2048m"

然而,这更像是一种解决方法,而不是真正的解决方案.如果多个用户同时上传大文件,您迟早会遇到同样的问题.你需要不断增加内存.您应该将文件上传解析器配置为将上传的文件存储在临时磁盘上,而不是完全存储在内存中.只要不清楚您使用的是哪个解析器,就无法给出合适的答案.但是,Apache Commons FileUpload 在幕后经常使用,您应该阅读以阈值大小"为关键字的文档,以配置上传文件的内存限制.当文件大小超过阈值时,就会写入磁盘.

However, this is more a workaround than a real solution. If multiple users concurrently uploads big files, you'll hit the same problem sooner or later. You would need to keep increasing memory for nothing. You should rather configure your file upload parser to store the uploaded file on temp disk instead of entirely in memory. As long as it's unclear which parser you're using, no suitable answer can be given. However, more than often Apache Commons FileUpload is used under the covers, you should then read the documentation with "threshold size" as keyword to configure the memory limit for uploaded files. When the file size is beyond the threshold, it would then be written to disk.

这篇关于如何增加 jBoss 服务器的堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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