ubuntu - Pandoc 和 Rstudio Knitr 内存泄漏

标签 ubuntu memory rstudio knitr pandoc

我正在尝试在具有 15GB 内存的私有(private) ubuntu amazon ec2 实例上编织一个 .Rmd 文件。我从源代码安装了 rstudio(RStudio 0.99.903 - Ubuntu 12.04+/Debian 8+(64 位)),然后在 here 之后链接了附带的 pandoc 版本。 .

$ sudo ln -s /usr/lib/rstudio/bin/pandoc/pandoc /usr/local/bin
$ sudo ln -s /usr/lib/rstudio/bin/pandoc/pandoc-citeproc /usr/local/bin

并在 PATH 中确认了它

ubuntu@ip-172-31-46-87:~$ pandoc -v
pandoc 1.15.2

从命令行调用 knitr

Rscript -e "rmarkdown::render('Observed.Rmd')" &> run.txt

我可以成功编织小试运行。

然而,当我尝试更大的运行时,我得到了错误

/usr/local/bin/pandoc +RTS -K512m -RTS SingleSpecies.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output SingleSpecies.html --smart --email-obfuscation none --self-contained -M2GB +RTS -K64m -RTS --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/ubuntu/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/h/default.html --number-sections --variable 'theme:spacelab' --include-in-header /tmp/RtmpWXb9A4/rmarkdown-str58570a61934.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/h/highlight --variable navigationjs=/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/h/navigation-1.0 
Error: pandoc document conversion failed with error 127
Execution halted
Warning message:
system call failed: Cannot allocate memory 

我已经尝试增加堆大小,继另一个 SO question ,通过添加到 YAML

output: 
  html_document:
    keep_md: yes
    number_sections: yes
    theme: spacelab
    toc: yes
    pandoc_args: [
    "-M2GB", "+RTS", "-K64m", "-RTS"
    ]

我也试过

self_contained: no

从中我可以看到编织的数字总共只有40MB

ubuntu@ip-172-31-21-194:~/Whales$ du SingleSpecies_files/ -sh
40M     SingleSpecies_files/

在 e2c 上,我以五分钟为增量跟踪内存。

enter image description here

而且我可以看到 knitr(或 pandoc)开始消耗内存,在五分钟内超过 10GB。是什么导致了这种泄漏?是的,有几十个数字,一些来自 ggmap,但它们远未说明所有内存分配。我认识到这是不可重现的,但我已经尽力做到彻底。欢迎所有建议。

我怀疑因为我在 rstudio 之外运行 knitr,所以有一个 rstudio 环境变量可以稳定大型 knitr 运行?

最佳答案

在 ubuntu 14.04 中使用当前版本的 RStudio 这两个命令中的任何一个都会使 ubuntu 加载越来越多的内存直到崩溃:

Sys.setenv(LANG = "en")
Sys.setlocale("LC_TIME", "en_US")

关于ubuntu - Pandoc 和 Rstudio Knitr 内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39319558/

相关文章:

ruby-on-rails - 内存在 Ruby 中是如何工作的?

python - apache上的python flask应用程序的随机问题

r - 在函数内调用 `odbc` 连接未显示在 RStudio 连接 Pane 中

r - 有没有办法在 RStudio 中禁用环境 Pane ?

r - ggplot 的 Shiny 切割顶部

linux - 在 Ubuntu 操作系统上安装 Thingsboard CE 时出错

perl - 如何计算 Perl 中出现的奇数次?

C# - 在 block 末尾自动释放内存

c++ - 在 Ubuntu 中使用 Visual Studio 运行 C++ 文件时出错

java - 同步mysql数据库和文件夹