Why do cell arrays take up so much more memory than arrays?
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 28 Feb 2019
Modificato: MathWorks Support Team
il 21 Giu 2023
Why do cell arrays take up so much more memory than arrays?
>> v1 = 1;
>> v2 = {1};
>> whos Name Size Bytes Class Attributes
v1 1x1 8 double
v2 1x1 120 cell
Risposta accettata
MathWorks Support Team
il 21 Giu 2023
Modificato: MathWorks Support Team
il 21 Giu 2023
The reason that cell arrays take up so much more memory is because they require a lot more overhead to store metadata about each element in the cell array, since each element could have a different type, size, etc.
Please refer to the following link for more information on strategies for efficient memory usage, particularly for cell arrays that have overhead.
To view the documentation in MATLAB 2017b, run the below command:
>> web(fullfile(docroot, 'matlab/matlab_prog/strategies-for-efficient-use-of-memory.html'))
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Multidimensional Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!