out memory problem
显示 更早的评论
hi, My array of data is 211,231*4,when process it I got this error:
Out of memory. Type HELP MEMORY for your options. keep in mind, I use clear ,close matlab and open it what I have to do to get over this error.
Thanks in advance
回答(2 个)
Jan
2011-10-10
0 个投票
Do you mean a [211'231 x 4] array? This array has 6.7 MB only, such that the must be another large array, which occupies much more memory.
Please post the corresponding source code, which is used to the create the array.
3 个评论
huda nawaf
2011-10-10
Jan
2011-10-10
What do you want to achieve? Please search in this forum and the net for the term "pre-allocation".
Walter Roberson
2011-10-10
Please take some time, Huda, to read about "vectorization" in MATLAB. You have been using MATLAB for some time now; it is time for you to study that topic and put it in to practice.
And, like Jan says, pre-allocate.
Walter Roberson
2011-10-10
Is that 211231 x 4, each entry a double precision number (8 bytes), or is it 211 x 231 with each entry a 4 byte number, or is it 211 x 231 x 4, each entry a double precision number (8 bytes)?
If it is 211231 x 4 double-precision entries, that should be only 6.4 megabytes; if you are unable to allocate a 6.4 megabyte array then you are too short on memory to do anything practical.
Please show the exact call you use to allocate the memory.
For example, if you were using
A = zeros(211231*4)
then we would immediately diagnose the problem as being that when you supply only a single scalar size to zeros() (or ones(), or rand()) then a square matrix is constructed that is that number of rows and columns.
11 个评论
huda nawaf
2011-10-10
huda nawaf
2011-10-12
Walter Roberson
2011-10-12
This is pretty much the same problem I solved for you over in http://www.mathworks.com/matlabcentral/answers/17949-problem-in-sprintf
the whole code after the fclose() can be replaced with a reshape().
huda nawaf
2011-11-28
Walter Roberson
2011-11-28
It might help to stop making so many copies of variables.
fid = fopen('d:\matlab\R2011a\bin\flixsterdata\finalflix0.txt','r');
c = textscan(fid, '(%g,%g)\t%g');
fclose(fid);
flix0 = accumarray([c{1}, c{2}], c{3}]);
By the way, what is max(c{1}) and max(c{2}) ?
huda nawaf
2011-11-29
Walter Roberson
2011-11-29
Urrr, you will definitely want to use a cell array or sparse matrix for that -- accumarray would need about 12 Gb to store that matrix in non-sparse form.
huda nawaf
2011-11-29
Walter Roberson
2011-11-29
I never looked up the storage requirements for sparse arrays.
What do you mean by "dynamic array" in this context?
huda nawaf
2011-11-30
Walter Roberson
2011-11-30
I never did find out what problem it is you are really trying to deal with -- though I did ask a few times.
类别
在 帮助中心 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!