Stop MATLAB when not enough memory

6 次查看(过去 30 天)
I use Window 10 64 bit, 24 GB RAM, MATLAB R2016a. In occasion when I run data with big size, memory is full 100%. The computer is hang and it is unable to close MATLAB or do anything else but restart.
My question is how to avoid this issue. For example if there is an pop-up to quit program when memory is full 100%, or some warning of full memory. It will allow me to reduce data size before running, or clear unused data... instead of restart the hung computer as I must do right now.
Thank you.
  1 个评论
KSSV
KSSV 2016-9-29
There is an option to check memory in matlab. Doc memory. You can check how much memory is left and put some limit on your own, and using if statement you can either exit matlab or break/ stop the code. But, I don't think this is the solution for the problem.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2016-9-29
One thing that can help is to use Preferences -> Workspace and enable "Limit the maximum array size to a percentage of RAM" and choose a size there.
When you have that in effect, it does not control the total memory to be used, but when you ask to create or assign into an array and that would make that particular array larger then the limit you set, then MATLAB would throw an error.
This will not deal with the issue of just accumulating enough variables in total that the memory fills up. For example if you limit to 75% but then build 7 variables each of which fills up 15% of memory, you would still run out of memory (7*15% = 105%).

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by