why I get "out of memory" error when i use zeros(60000)?

4 次查看(过去 30 天)
Hi. when I use zeros(60000) I receive out of memory error.My matlab product is MATLAB R2014a 64 bit. can you help me please?

回答(2 个)

Thorsten
Thorsten 2015-11-16
You tried to allocate 60000*60000*8 = 28.8 GByte. That's seems to be too much for Matlab on your machine.
  3 个评论
Thorsten
Thorsten 2015-11-16
编辑:Thorsten 2015-11-16
This traditional convention is not recommended, as far as I understand from https://en.wikipedia.org/wiki/Gigabyte:
In 1998 the International Electrotechnical Commission (IEC) published standards for binary prefixes, requiring that the gigabyte strictly denote 1000^3 bytes and gibibyte denote 1024^3 bytes. By the end of 2007, the IEC Standard had been adopted by the IEEE, EU, and NIST, and in 2009 it was incorporated in the International System of Quantities. Nevertheless, the term gigabyte continues to be widely used with the following two different meanings: [namely 1000^3 and 1024^3]
Guillaume
Guillaume 2015-11-16
Yes, the notation is not recommended. It is however the one used by the memory manufacturers and the one used by Windows to report the amount of memory your computer has.

请先登录,再进行评论。


Guillaume
Guillaume 2015-11-16
编辑:Guillaume 2015-11-16
zeros(60000) is the same as
zeros(60000, 60000)
A 60,000 x 60,000 matrix of doubles requires approximately 27 GB of memory.
If you just want a vector of 60,000 elements:
zeros(1, 60000)
  2 个评论
Stefan Raab
Stefan Raab 2015-11-16
Hey,
if you use the command
memory
you can see the Maximum possible array size. In my case:
Maximum possible array: 17896 MB (1.877e+10 bytes)
A double variable needs 64 bit or 8 byte of memory, so I can save 1.877e+10 bytes / 8 bytes = 2.3463e+09 double variables in one array. The resulting size for a quadratic matrix is then sqrt(2.3463e+09) = 48438. Therefore is a quadratic matrix with size 60000 too big.
Note: If there are many zeros in your matrix, I think you should have a look at sparse matrices: http://www.mathworks.com/help/matlab/ref/sparse.html
Kind regards, Stefan
Walter Roberson
Walter Roberson 2015-11-16
Note: the command memory() is only available on MS Windows systems.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by