加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

R Windows 64bit版本中不支持长矢量但错误

发布时间:2020-12-14 02:09:59 所属栏目:Windows 来源:网络整理
导读:我正在尝试测试当前R版本中的内存限制. runtest - function(size) { x - "testme" while(01) { x - c(x,x) size - object.size(x) # size of x when fail }} 通过在我的笔记本电脑上的控制台中运行runtest(大小),我收到以下错误: runtest(size)Error: canno
我正在尝试测试当前R版本中的内存限制.

runtest <- function(size) {
  x <- "testme"
  while(0<1) {
    x <- c(x,x)
    size <<- object.size(x)  # size of x when fail
  }
}

通过在我的笔记本电脑上的控制台中运行runtest(大小),我收到以下错误:

> runtest(size)
Error: cannot allocate vector of size 4.0 Gb
In addition: Warning messages:
1: In structure(.Call(C_objectSize,x),class = "object_size") :
  Reached total allocation of 7915Mb: see help(memory.size)
2: In structure(.Call(C_objectSize,class = "object_size") :
  Reached total allocation of 7915Mb: see help(memory.size)
3: In structure(.Call(C_objectSize,class = "object_size") :
  Reached total allocation of 7915Mb: see help(memory.size)
4: In structure(.Call(C_objectSize,class = "object_size") :
  Reached total allocation of 7915Mb: see help(memory.size)
> size
2147483736 bytes
>

这个大小看起来非常接近人们之前提到的2 ^ 31-1限制.然后我尝试在我们升级的桌面上运行相同的代码,使用128GB的RAM,并将64位版本的快捷方式中的变量设置为100GB的最大内存使用量.这是我得到的新错误:

Error in structure(.Call(C_objectSize,),class = "object_size"):
  long vectors not supported yet: unique.c: 1720
> size
8589934680 bytes
>

此8.5GB限制是否与在Windows O / S(特别是Windows 7企业版)中运行有关?我认为R帮助文件(http://stat.ethz.ch/R-manual/R-devel/library/base/html/Memory-limits.html)解释了这一点,但我无法理解它的含义(不是我的专业领域).

解决方法

看一下 size.c和 unique.c的来源,看起来用于改进object.size的哈希不支持长向量:

/* Use hashing to improve object.size. Here we want equal CHARSXPs,not equal contents. */

/*  Currently the hash table is implemented as a (signed) integer
    array.  So there are two 31-bit restrictions,the length of the
    array and the values.  The values are initially NIL (-1).  O-based
    indices are inserted by isDuplicated,and invalidated by setting
    to NA_INTEGER.
*/

因此,它是一个令人窒息的object.size.如何调用数字(2 ^ 36)来查看是否可以创建这么大的对象(应该是64GB).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读