可以解决垃圾收集器在R中完成工作后的可变变化

  • 本文关键字:工作 变化 解决 收集器 r
  • 更新时间 :
  • 英文 :


如果可能的话,我想知道垃圾收集器(GC)是否在R中更改变量的地址。换句话说,假设以下代码:

library(pryr)
x <- 0:1024
addr <- address(x)  # save address of variable "x" in "addr"
    .
    .
    .
*(execution of operations that creates/destroys many small/big objects in memory, which will likely make the GC to be called...)*
    .
    .
    .
if (addr != address(x))
{
   print("Address of x changed!")
}

消息Address of x changed!会打印出来吗?

对R不太确定,但通常是可能的。GC可以出于多个原因移动对象。例如,将对象从托儿所空间转移到成熟空间(世代GC)或使用标记 - 连接/半空间技术扫除死对象。

最新更新