why I get "out of memory" error when i use zeros(60000)?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (2)
Thorsten
le 16 Nov 2015
You tried to allocate 60000*60000*8 = 28.8 GByte. That's seems to be too much for Matlab on your machine.
3 commentaires
Thorsten
le 16 Nov 2015
Modifié(e) : Thorsten
le 16 Nov 2015
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
le 16 Nov 2015
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
le 16 Nov 2015
Modifié(e) : Guillaume
le 16 Nov 2015
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 commentaires
Stefan Raab
le 16 Nov 2015
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
Voir également
Catégories
En savoir plus sur Function Creation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!