Javascript增加最大数组大小 [英] Javascript Increase max array size
问题描述
我正在尝试创建一个大小 2 ^ 32 = 4294967296
的数组,因为我试图通过运行筛选算法将所有素数加到2 ^ 32 。但是,该数组中的任何操作都会出现以下错误:
致命错误:CALL_AND_RETRY_LAST分配失败 - 处理内存不足
中止陷阱:6
在上述情况下我该怎么办?
数组不能那么大,最大长度为2 32 -1。根据 ECMAScript 规范,
每个Array对象都有一个length属性,其值始终为
非负整数,小于2 32 。 / p>
当且仅当
ToString(ToUint32(<) em> P ))等于 P 且ToUint32( P )不等于
到2 32 - 1。
I am trying to create an array of size 2^32 = 4294967296
, because I am trying to get all the prime numbers till 2^32 by running the sieve algorithm. However any operation in that array I get the following error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Abort trap: 6
What can I do in above situation?
Arrays can't be that big, the maximum length is 232-1. According to ECMAScript spec,
Every Array object has a length property whose value is always a nonnegative integer less than 232.
A String property name P is an array index if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 232−1.
这篇关于Javascript增加最大数组大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!