内存不足:Java堆空间,但是在查看堆空间时,它最多使用50 MB [英] Getting Out Of Memory: Java heap space, but while viewing heap space it max uses 50 MB

查看:220
本文介绍了内存不足:Java堆空间,但是在查看堆空间时,它最多使用50 MB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASANT运行一个指向NARS.jar文件的xml文件. (我没有NARS.jar的项目文件)

I'm using ASANT to run a xml file which points to a NARS.jar file. (i do not have the project file of the NARS.jar)

我收到"java.lang.OutOfMemoryError:Java堆空间.

I'm getting "java.lang.OutOfMemoryError: Java heap space.

在运行NARS.jar时,我使用VisualVM来查看堆,它说最大占用了50 MB的堆空间.

I used VisualVM to look at the heap while running the NARS.jar, and it says that it max uses 50 MB of the heapspace.

我已将堆空间的初始大小和最大大小设置为512 MB.

I've set the initial and max size of heapspace to 512 MB.

有人有可能犯错的想法吗?

Does anyone have an ide of what could be wrong?

我有1 GB的物理内存并创建了5 GB的页面文件(用于测试).

I got 1 GB physical Memory and created a 5 GB pagefile (for test purpose).

谢谢.

推荐答案

您的应用可能正在尝试分配超出您的512m限制的内存,因此即使仅使用了50m,您也会看到内存不足错误.为了测试这一点,我将设置:

Your app may be trying to allocate memory that exceeds your 512m limit, thus you see an outofmemory error even though only 50m is being used. To test this, I would set:

-Xms512m -Xmx1024m

-Xms512m -Xmx1024m

看看会发生什么.我还会尝试一个较小的测试文件,例如1g.继续减小文件大小,直到不再看到错误为止.如果成功,那么麻烦就在于您要尝试执行的操作以及您尝试执行的操作会占用过多的内存.是时候寻找替代方法了.

And see what happens. I would also try a smaller test file, say 1g. Keep reducing the file size until you stop seeing the error. If you succeed, then the trouble is that what you're trying to do and the way you're trying to do it takes too much memory. Time to look for an alternate approach.

这篇关于内存不足:Java堆空间,但是在查看堆空间时,它最多使用50 MB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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