r - 错误 : Maximal number of DLLs reached

标签 r dll package

我正在编写一个依赖于许多其他包的 R 包。当我在 session 中加载太多包时,我经常收到此错误:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/proxy/libs/proxy.so':
  `maximal number of DLLs reached...

本帖Exceeded maximum number of DLLs in R指出问题在于基本 R 代码的 Rdynload.c:#define MAX_NUM_DLLS 100
除了从源代码修改和构建之外,有没有办法绕过这个问题?

最佳答案

增加这个数字当然是“可能的”......但它也需要花费一些
(添加到 R 的固定内存占用)。

我没有设置这个限制,但我很确定这也是为了提醒 userR 在她/他的 R session 中“清理”一点,即不要不必要地加载包命名空间。我还无法想象您需要 > 100 个包裹 |在 R session 中加载的命名空间。
OTOH,现在一些包有很多依赖项,所以我同意这至少可能比过去更频繁地发生意外。

当然,真正的解决方案是改进代码,从相对较少的“DLLinfo”结构(比如 32)开始,然后根据需要分配更多的批次(比如 32)。

非常欢迎对 R 源代码(位于 https://svn.r-project.org/R/trunk/ 的颠覆中的开发主干)的补丁!

---- 2017 年 1 月 26 日添加:同时,我们有一个 public bug report关于这个,一个建议的补丁(这还不够好:打开文件的数量总是有操作系统相关的限制),今天,R 核心成员@TomasKalibera 关闭了该错误报告,他实现了最大数量的新代码加载的 DLL 设置为

pmax(100, pmin(1000, 0.6* OS_dependent_getrlimit_or_equivalent()))



等等 Windows 和 Linux(尚未测试,但“几乎可以肯定”macOS),限制应该比以前高得多。

----- 更新 #2(写于 2018 年 1 月 5 日):
在 17 年 10 月,通过以下对源代码的提交(仅限 R 的开发版本!),使上述更改更加自动化。

r73545 | kalibera | 2017-10-12 14:41:20

Increase the number of DLLs that can be loaded by default. If needed, increase the soft limit on open files.



并在帮助页面 ?dyn.load ( https://stat.ethz.ch/R-manual/R-devel/library/base/html/dynload.html ) ulimit -n <num_open_files>现在提到了(部分 注意 靠近底部)。

所以你可能会考虑使用 R 的开发版本,直到它在 4 月份成为“主流”。
或者,您可以(在终端/ shell 中)

ulimit -n 2048



然后从该终端启动 R。 Tomas Kalibera 提到这适用于 macOS。

关于r - 错误 : Maximal number of DLLs reached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36974206/

相关文章:

r - 相同的稀疏矩阵,不同的对象大小

r - 如何为大量变量运行 bigglm 函数

windows - 您可以将 OCaml 项目本地编译为 Windows 库吗?

python - 如何刷新 sys.path?

git - 致命的 : could not read Username for 'https://gitlab.com' : terminal prompts disabled

R ggplot 箱线图 : change y-axis limit

r - 导入 .csv 时将列转换为行

c# - 引用 System.Windows.Automation

c++ - 在注入(inject)的 DLL 中调用函数?

centos - Linux(Centos)中的软件包版本?