macOS M1 上的 R 使用交换区而不是 RAM - 如何增加 RAM 使用?

asa*_*ica 11 macos ram r apple-m1 macos-monterey

我有一台 M1 macbook pro,运行专用的 R aarch64 版本,并且运行 macOS Monterey。

R version 4.1.0 (2021-05-18) 
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 12.2.1
Run Code Online (Sandbox Code Playgroud)

R 拒绝使用超过 1.8GB 的​​ RAM(8GB 之外),而是更喜欢使用交换,导致在运行内存昂贵的东西时计算速度慢得可笑。

htop 说明 RAM 上的交换使用情况

我已经尝试了我所知道的各种技巧来让 R 使用更多内存 - 请不要关闭以提出其中一个作为答案的问题:

  1. memory.limit()并且memory.size()是 Windows 特定的并且不适用。gc()确实有效并给了我:
$ R_MAX_VSIZE=8000000 R_MAX_MEM_SIZE=8gb R --vanilla -e "gc()"

R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
[...]

> gc()
         used (Mb) gc trigger (Mb) max used (Mb)
Ncells 273458 14.7     666994 35.7   413917 22.2
Vcells 458587  3.5    8388608 64.0  1824664 14.0
Run Code Online (Sandbox Code Playgroud)
  1. 无论是在调用 R 中还是在调用 R 时,设置像R_MAX_VSIZE=8gb或 这样的环境变量都不起作用:尽管 RAM 空闲了 75%,但交换仍然被大量使用。R_MAX_MEM_SIZE=8gb.Renviron

  2. 我读过有关减少系统交换性的内容,但我找不到在 MacOS 12 中执行此操作的干净方法。

我该怎么做才能让 R 在 M1 aarch64 系统上使用更多 RAM?