Filter löschen
Filter löschen

how resolve Get out of memory error in Matlab?

2 Ansichten (letzte 30 Tage)
sasa
sasa am 26 Aug. 2014
Kommentiert: sasa am 6 Sep. 2014
I have matlabR2013a on a 4GiG RAM system and window7. I have the code below:
c = x'*x/(n-d);
x is a 28944*30 double matrix and n and d are 1*1 matrix(a number). when I run this line of code I got error: Out of memory. Type HELP MEMORY for your options.
how can I fix this error? I increase the amount of virtual heap memory but no thing changed!
thanks for your help.

Antworten (1)

Guillaume
Guillaume am 26 Aug. 2014
If Windows 7 is the 32 bit version, then Matlab can't use more than 2 GB (3GB if you mess about with the OS). If you're using the 32 bit version of Matlab on a 64 bit OS, then you're limited to under 4 GB.
However, the memory footprint of the arrays you're listing is minimal. On my machine x is about 6 MB. You'll need another 6MB free to temporarily store the transpose and possibly 6MB for x/(n-d), but it shouldn't tax your system.
Check how much memory you have free with
memory
In particular, Maximum possible array tells you what is the max. size of a single array.
Check how much the existing variables use with
whos
Clear the variables you don't need.
FInally have a look at this page (and of course do type HELP MEMORY as instructed).
  5 Kommentare
Guillaume
Guillaume am 27 Aug. 2014
No, it's not a restriction of matlab. If you do want to create a 28944 x 28944 matrix, it will use over 6GB of memory regardless of the program.
You could halve the memory usage by switching to single instead of double but it's still more memory than you have.
If you do want to calculate an array of that size, your only option is to calculate part of it, save it to disk, calculate another part, save it to disk, and so on.
sasa
sasa am 6 Sep. 2014
Thanks alot Guillaume.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by