简体   繁体   English

Matlab内存管理; java堆不足

[英]Matlab memory management; insufficient java heap

I was hoping that someone on here would be able to explain or point me to a webpage where I could learn more about Matlab's memory management. 我希望这里的人能够向我解释或指向一个网页,在该网页上我可以了解有关Matlab内存管理的更多信息。 I know that Matlab is a higher level language so it takes care of memory management, which is good and bad. 我知道Matlab是一种高级语言,因此它负责内存管理,这是好是坏。 Good cause I don't need to worry about it and bad cause I have no idea what it is doing under the hood. 好的原因,我不必担心,而不好的原因,我不知道它在做什么。 The reason I ask is lately I've been getting this error message a lot. 我问的原因是最近我收到了很多此错误消息。

Insufficient Java heap memory to continue operation 

Granted I'm using a mid 2010 15" Macbook pro, with only 4 GB of RAM, not really the best computer to be perform all the image operations that I do. I know Matlab has a delete function, and I didn't know when/if it would be helpful to use this function to save memory? I have used the delete function before only in hardware related tasks when I am sending data through serial I delete my serial object. But beyond that should I be using delete for my own memory management? 当然,我使用的是2010年中期的15英寸Macbook pro,它只有4 GB的RAM,并不是真正执行所有图像操作的最佳计算机。我知道Matlab具有删除功能,并且我不知道什么时候/如果使用此功能可以节省内存?我仅在通过串行发送数据时才在硬件相关任务中使用过delete函数,我删除了串行对象,但除此之外,我还应该使用delete自己的内存管理?

See this question . 看到这个问题 To prevent Java heap error, you will need to change JVM options. 为防止Java堆错误,您将需要更改JVM选项。 Change the default value in Matlab preferences or create a new java.opts file with -Xmx (and optionally -Xms ) options, eg, 更改Matlab首选项中的默认值,或使用-Xmx (以及可选的-Xms )选项创建一个新的java.opts文件,例如,

-Xmx1g

To set the equivalent of the -Xmx parameter in more recent versions of Matlab, go to Preferences (on the toolbar/ribbon), then 要在最新版本的Matlab中设置-Xmx参数的等效项,请转到“偏好设置” (在工具栏/功能区上),然后

MATLAB > General > Java Heap Memory

There is a slider there. 那里有一个滑块。 Matlab will have to be restarted for this to take effect. Matlab将必须重新启动才能生效。

There is a warning about doing this, but as I wrote elsewhere , I think it can be ignored. 有这样做的警告 ,但是正如我在其他地方写的 ,我认为可以忽略它。


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. 如果您只能通过终端对Matlab进行非图形访问,则上述命令的作用是~/.matlab/R2016a/matlab.prf添加到~/.matlab/R2016a/matlab.prf ,因此您可以手动执行。

JavaMemHeapMax=I36532

This line appeared after I used the slider to set the preference to 36,532 MB and quit Matlab. 在使用滑块将首选项设置为36,532 MB并退出Matlab之后,出现了这一行。 If you can't find your matlab.prf file, check here . 如果找不到您的matlab.prf文件,请点击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM