MATLAB using too much RAM

조회 수: 6 (최근 30일)
Desmond Johnson
Desmond Johnson 2015년 3월 1일
편집: per isakson 2015년 3월 10일
I am having a problem with MATLAB regarding RAM usage. I am trying to run a function (code below) and every time I plot the function using surf my RAM usage spikes up to an absurd amount causing the system to write to the hard drive drastically slowing down system performance. My questions is if there is anyway I can reduce the RAM usage. I am new to MATLAB so if the answer is obvious I apologize for my ignorance. I am running MATLAB 2014a on Mac OS X with 16gb of 1600Mz DDR3 Memory.
x=randn(1,10000);
a=sort(x);
y=x;
b=sort(y);
[X,Y]=meshgrid(a,b);
z=(1000/sqrt(2*pi).*exp(-(X.^2/2)-(Y.^2/2)));
subplot(2,2,1)
surf(X,Y,z);
shading interp
axis tight
colormap cool
subplot(2,2,2)
surf(X,Y,z);
shading interp
Thanks in advance for the help.

채택된 답변

per isakson
per isakson 2015년 3월 2일
편집: per isakson 2015년 3월 10일
On R2013b (64bit Windows7 32GB) your script run without error. It increased memory usage, according to the task manager, from 5.6 to 21.1 GB. See screen clip below.
I cannot see there is much the user can do about that. Did you try single precision? However, do you really need the large matrices
>> whos X Y
Name Size Bytes Class Attributes
X 10000x10000 800000000 double
Y 10000x10000 800000000 double
I replaced
x=randn(1,10000);
by
x=randn(1,1000);
The script run in no time, the increase in memory usage was hardly visible and I cannot see any difference in the result on screen.
&nbsp
  댓글 수: 1
Desmond Johnson
Desmond Johnson 2015년 3월 2일
Thank you so much for the help unfortunately I do need those exact numbers because it is for a homework assignment for my engineering class. I have already informed my professor of the resource issue this code causes so hopefully he will modify the numbers we need.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by