在命令行Java堆空间错误 [英] Java Heap Space error from command line

查看:269
本文介绍了在命令行Java堆空间错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试创建一个小工具,它读取Excel和时发送电子邮件。我使用ApachePOI库这一点。当我执行code从日食,最初我得到了 java.lang.OutOfMemoryError:GC开销超过限制错误。然后,我添加 -Xms1024m 在Eclipse和程序的VM参数在Eclipse中工作得很好。

I have tried to create a small utility which reads excel and sends email. I am using ApachePOI library for that. When I executed the code from eclipse, initially I got java.lang.OutOfMemoryError: GC overhead limit exceeded error. Then I added -Xms1024m in the VM Arguments of eclipse and program worked fine in eclipse.

然后我导出的一套Java程序和库成RunnableJar和捆绑的依赖库。

Then I exported the set of java programs and libraries into RunnableJar and bundled the dependent libraries.

现在从命令行当我执行命令

Now from command line when i execute the command

java -Xms1024m -jar AutomateProcesses.jar

我仍然得到同样的错误。我无法弄清楚这个问题。可能有人请这方面的帮助?

I am still getting the same error. I am not able to figure out the issue. could someone please help in this regard?

推荐答案

您可以尝试

java -Xms512m -Xmx2048 -jar AutomateProcesses.jar

如果这仅仅是什么在这个VM这是我期望事情。如果java进程的一个库,然后生成一个单独的进程则库可能需要一些其他的选项来配置它。

If this is just whats going on in this VM which is what I expect. If the a library in the java process is then spawning a separate process then the library may need some other options to configure it.

编辑:

这是答案<一个href=\"http://stackoverflow.com/questions/10901808/what-is-the-difference-in-java-lang-outofmemory-gc-overhead-limit-exceeded-vs\">this问题指出这个错误是因为GC花费太多时间试图恢复记忆,并没有得到它。我不是很熟悉Appache POI但如果是从Java那么它可能是使用COM交谈,Excel调用到Excel的DLL。这可能是因为没有在库中,或者你使用它的方式错误,导致对象被锁定垃圾收集的,因此,GC的工作很辛苦,很少进展。

An answer to this question points out that this error is because the GC is spending too much time trying to recover memory and not getting it. I am not very familiar with Appache POI but if it is talking to Excel from java then it is probably using COM calls into the Excel DLLs. It may be that there is a bug in the library or the way that you use it, leading to objects being locked out of garbage collection and thus the GC works very hard with little progress.

您可以尝试找出code有这个问题到一个较小的测试用例?

Can you try to isolate the code that has this problem into a smaller test case?

帖子有类似的问题到这样的程度他们重写了他们处理在Excel单元格,以避免产生大量cellStyle对象的方式。

This post had a similar problem to such an extent that they re-wrote the way they were dealing with cells in Excel so as to avoid creating a large number of cellStyle objects.

在此类似,<一个href=\"http://stackoverflow.com/questions/7152950/heap-error-while-writing-xls-file-with-apache-poi?rq=1\">this人放弃了,写了他们的数据为CSV格式。

In a similar vein, this person gave up and wrote their data to CSV format.

这篇关于在命令行Java堆空间错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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