Possible Duplicate:
MATLAB: maximum pre-allocated size?
Is there a size limitation on creating a matrix in MATLAB? If so, where can I locate this information?
Memory is limited in Matlab only by the amount of memory (including virtual memory) made available to it by the operating system. Matrices are stored in memory as contiguous space, so if you have a matrix that would occupy 8GB of memory, you would need one big chunk of 8GB to be available to you in memory.
You can use the memory
command to provide detailed statistics about the memory available to you, including the amount of contiguous memory available for a single matrix. For example:
> memory
Maximum possible array: 677 MB (7.101e+008 bytes) *
Memory available for all arrays: 1601 MB (1.679e+009 bytes) **
Memory used by MATLAB: 446 MB (4.681e+008 bytes)
Physical Memory (RAM): 3327 MB (3.489e+009 bytes)
* Limited by contiguous virtual address space available.
** Limited by virtual address space available.
To calculate the array size that the Maximum possible array
value corresponds to, you simply divide by the number of bytes required by each array elements. From the memory
documentation:
Maximum Possible Array
Maximum Possible Array is the size of the largest contiguous free memory block. As such, it is an upper bound on the largest single array MATLAB can create at this time.
MATLAB derives this number from the smaller of the following two values:
* The largest contiguous memory block found in the MATLAB virtual address space * The total available system memory
To see how many array elements this number represents, divide by the number of bytes in the array class. For example, for a double array, divide by 8. The actual number of elements MATLAB can create is always fewer than this number.
Mathworks also provides detailed documentation on how to avoid Out of Memory
errors here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With