Any way how to go around the memory issue?

조회 수: 1 (최근 30일)
Anshuman S
Anshuman S 2021년 8월 1일
답변: Matt J 2021년 8월 1일
I am running a program with the following code
ntimemax=10000000; ngroupmax=300; dtime=0.0001; qmax1 = 10.2;
% define output interval and number of output data
doutput=1; noutput=(ntimemax-1)/doutput+1;
NMG2=zeros(noutput,ngroupmax);
NGT2=zeros(noutput,1); NMGT2=zeros(noutput,1); Num2 = zeros(noutput,1);
ntime=zeros(noutput,1); NG=zeros(noutput,ngroupmax); NMG=zeros(noutput,ngroupmax);
NGT=zeros(noutput,1); NMGT=zeros(noutput,1);
And this error shows up:
Out of memory. Type "help memory" for your options.
Error in new_2020_paper_results (line 38)
ntime=zeros(noutput,1); NG=zeros(noutput,ngroupmax);
NMG=zeros(noutput,ngroupmax);
Any way t solve this problem?
  댓글 수: 1
Chunru
Chunru 2021년 8월 1일
ntimemax=10000000; ngroupmax=300; dtime=0.0001; qmax1 = 10.2;
doutput=1; noutput=(ntimemax-1)/doutput+1;
% The size of NMG2=zeros(noutput,ngroupmax);
noutput * ngroupmax
ans = 3.0000e+09
A single matrix of this need 3G*8(bytes per data)=24GB of memory. You have a number of such data array. That requires a lot of memory. Try to reduce the size of the array to what is absolutely necessary.

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

답변 (1개)

Matt J
Matt J 2021년 8월 1일
Will the matrices be sparse? If so, use sparse() to build them.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by