java.lang.OutOfMemoryError:启动时的Java堆空间 [英] java.lang.OutOfMemoryError: Java heap space on startup

查看:556
本文介绍了java.lang.OutOfMemoryError:启动时的Java堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,我开始在MATLAB启动时遇到 java.lang.OutOfMemoryError:Java堆空间异常 - 在我运行任何代码或添加任何内容之前路径。 MATLAB加载的默认目录也没有文件。

A few days ago I began encountering a java.lang.OutOfMemoryError: Java heap space exception on startup of MATLAB - before I run any piece of code or add anything to the path. The default directory MATLAB loads also has no files on it.

我在Windows 7 64位上运行MATLAB R2012a。

I am running MATLAB R2012a on Windows 7 64 bit.

造成这种情况的原因是什么?

What could be causing this?

推荐答案

设置 -Xmx 更新版Matlab中的参数,转到偏好设置(在工具栏/功能区上),然后

To set the -Xmx parameter in more recent versions of Matlab, go to Preferences (on the toolbar/ribbon), then

MATLAB > General > Java Heap Memory

那里有一个滑块。必须重新启动Matlab才能生效。

There is a slider there. Matlab will have to be restarted for this to take effect.

有一个警告,但是:


注意:增加Java堆大小会减少可用于在数组中存储数据的内存量

Note: Increasing the Java heap size decreases the amount of memory available for storing data in arrays.

我想这意味着Matlab不会将数组存储在其Java堆空间中。但是,如果我们只是设定上限,这是否重要?我不这么认为。更具体地说,看看当我将上面的滑块设置为36 GB时会发生什么,Matlab启动并立即启动其虚拟内存(如 top 所示)达到39.9 GB。但物理内存使用仅约300 MB。因此,除非它实际上将某些东西放入该堆空间中,否则可用的物理内存不会减少。阵列。所以看起来这个警告可以忽略。

I guess this means that Matlab doesn't store arrays in its Java heap space. But does this matter if we are just setting the upper limit? I don't think so. More specifically, looking at what happens when I set the above slider to 36 GB, Matlab starts up and immediately its virtual memory (as seen with top) goes to 39.9 GB. But physical memory use is only around 300 MB. So, unless it actually puts something in that heap space, there won't be less physical memory available to e.g. arrays. So it looks like this warning can be ignored.

如果您只通过终端对Matlab进行非图形访问,上面命令的效果是将以下行添加到〜/ .matlab / R2016a / matlab.prf ,因此您可以手动执行此操作。

In case you only have non-graphical access to Matlab through a terminal, the effect of the above command was to add the following line to ~/.matlab/R2016a/matlab.prf, so you could do that manually instead.

JavaMemHeapMax=I36532

在我使用滑块将首选项设置为36,532 MB并退出Matlab后出现此行。如果找不到 matlab.prf 文件,请检查这里

This line appeared after I used the slider to set the preference to 36,532 MB and quit Matlab. If you can't find your matlab.prf file, check here.

这篇关于java.lang.OutOfMemoryError:启动时的Java堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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