可能重复:
MATLAB:最大预分配大小?
在MATLAB中创建矩阵是否存在大小限制?如果有,我在哪里可以找到这些信息?
可能重复:
MATLAB:最大预分配大小?
在MATLAB中创建矩阵是否存在大小限制?如果有,我在哪里可以找到这些信息?
在Matlab中,内存仅受操作系统提供的内存(包括虚拟内存)限制。矩阵被作为连续空间存储在内存中,因此如果您有一个需要占用8GB内存的矩阵,则需要在内存中有一块8GB大小的连续内存可用。
您可以使用memory
命令提供有关可用内存的详细统计信息,包括单个矩阵可用的连续内存量。例如:
> 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.
要计算 最大可能数组
值对应的数组大小,只需将其除以每个数组元素所需的字节数即可。参考memory
文档:
Mathworks也提供了详细的文档,介绍如何避免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.
内存不足
错误,文档链接在这里。是的,您受到计算机可用RAM数量的限制。您可以使用MATLAB命令来检查此限制。
feature( 'memstats' )