是否存在“内存不足"的阈值?错误? [英] Is there a Threshold for "Out of Memory" error?
问题描述
当我使用类似的代码时,
When I use some code like,
x = randi(100,[1000 1000000]);
我收到Out of Memory
错误.
但是,只要有,
x = randi(100,[1000 500000]);
我没有收到任何错误,但是我的笔记本电脑几乎停止工作了!
I don't get any error but my laptop almost stops working!
,有时候我要花一个force shutdown
.
我真的很喜欢Out of Memory
错误!
第1季度和第2季度:该错误是否存在阈值 ,我可以调整?
Q1+Q2: Is there a threshold for that error, which I could adjust?
Q3:或其他任何建议(可能会限制MATLAB可以访问的内存)?
Q3: Or any other suggestions (maybe limit the memory that MATLAB can have access)?
谢谢
推荐答案
A1:是的,内存就是宝藏
虽然内存是一个限制,但是您观察到的 几乎停止工作" 与与CPU绑定的处理有关,该处理与任务相关联以计算所有500,000,000的值元素并存储它们.如您在 A3 中看到的那样,此尝试需要4GB的RAM存储空间来仅处理 x
.
A1: Yes, the Memory is the Treshold
While the Memory is a limit, your observation of "almost stops working" is related to the CPU-bound processing associated with a task to calculate value for all 500,000,000 elements and get 'em stored. As you can see in A3 this attempt takes 4GB RAM storage to handle just the x
.
如果您的问题需要更大的对象,请获取更多的空间来存储它,如果您的CPU受限的观察很重要,请从分布式处理(无论是Cloud还是Grid)中获取计算,以减轻本地主机的负担.>
A3:是的.使用whos
检查消耗的MATLAB内存
If your problem requires larger objects, get more space to store it, if your CPU-bound observation matters, go get the computation from distributed processing ( be it a Cloud or a Grid ) to off-load your localhost.
mCloud:1> x = randi( 100, [1000 500000] );
mCloud:2> whos
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
ans 1x70 757 cell
x 1000x500000 4000000000 double
Total is 500000070 elements using 4000000757 bytes
mCloud:3>
这篇关于是否存在“内存不足"的阈值?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!