如果达到最大内存,如何进行代码中断

时间:2014-06-08 16:51:57

标签: r

在RStudio中,在某些情况下,我的某些代码达到了最大内存,例如:

Warning messages:
1: In dlData$unique_id <- paste(dlData$institution_key,  ... :
  Reached total allocation of 16322Mb: see help(memory.size)
2: In dlData$unique_id <- paste(dlData$institution_key,  ... :
  Reached total allocation of 16322Mb: see help(memory.size)
3: In `$<-.data.frame`(`*tmp*`, "unique_id", value = c("100003|19920822",  ... :
  Reached total allocation of 16322Mb: see help(memory.size)
4: In `$<-.data.frame`(`*tmp*`, "unique_id", value = c("100003|19920822",  ... :
  Reached total allocation of 16322Mb: see help(memory.size)

通常,在这种情况下,代码仍然继续运行到下一步,但我不确定我的代码是否真的运行良好。如果达到最大内存,是否有可能破坏代码,即R?

中的任何设置

1 个答案:

答案 0 :(得分:2)

您可以通过设置

使代码停在任何警告消息上
options(warn=2)

如果您的代码足够干净(即,您从未收到任何其他警告),那么这应该可以正常工作。我不知道如何抓住一个特定的警告。