-
-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
knit_meta_id grows out of control when kableExtra is loaded #1538
Comments
Yes!! I've been fighting this for the last few days trying to figure out what is going on! I have a server with 192GB of ram, and after the third time or so of running a render to pdf using kableExtra, my rsession grinds to a halt utilizing ALL available ram. I have to bring the server down in order to clear the session. I have been trying to troubleshoot this, and it seems like the more kable tables I have in my template, the quicker this happens. Does that make sense in terms of the underlying bug? |
What's interesting is that I can recreate this bug using the code above, but as soon as I call It looks like But having an initial value shouldn't cause the value to get LARGER for each additional render. Given the code in It seems like a quick workaround is to just call |
It's overkill, but i've added BUT, i no longer have the runaway memory issue! My server takes 35 minutes to boot (a problem for another day), so I am so happy to have a workaround for this! |
It looks like knit_meta_add = function(meta, label = '') {
if (length(meta)) {
meta_id = attr(.knitEnv$meta, 'knit_meta_id')
.knitEnv$meta = c(.knitEnv$meta, meta)
attr(.knitEnv$meta, 'knit_meta_id') = c(meta_id, rep(label, length(meta)))
}
.knitEnv$meta
} So we can see that it reps the label param for the length of the meta param as though it assumes the length of label is 1. However, It looks like this chunk of code in |
@nikkoc Thanks for investigating the issue and pointing out the root cause! You were absolutely correct, and I have fixed it in knitr. You may install the development version via remotes::install_github('yihui/knitr') |
…tly provided and not UTF-8 Emily Riederer (1): Implement sass / scss engines (#1666) Han Oostdijk (1): engine cat honors options echo and eval (#1618) Hiroaki Yutani (1): Make kable(format = "pandoc") fall back to markdown format when data has 0 row (#1678) Inferrator (1): kable -- added a `label` argument that allows specifying a LaTeX refe… (#1655) Sebastian Meyer (1): make stitch template work without knitr being attached (#1668) Walter Zhang (1): Added complex data type to `is_numeric` (#1663) Yihui Xie (59): remove file_ext again; hoping spelling will be updated before the next knitr release... use xfun::read/write_utf8() warn against non-UTF8 encodings! force UTF-8 in pandoc() import xfun::read/write_utf8() drop the encoding argument in Sweave2knitr() remove the encoding argument in knit2pandoc() and knit2pdf() only support UTF-8 knit2html() import xfun::file_string() remove the `encoding` argument in knit2wp() fix #1644: quote the output path in pandoc() no CRAN incoming check pandoc may not be installed on certain CRAN platforms; of course, it is the glorious Solaris! also try rmarkdown::pandoc_exec() to find pandoc, and use system2() instead of system() lost pandoc_cfg() in 9bfec7d11fa49ecfe4525abe2c2125ddeba77a57 warn only against the encoding value that is explicitly provided and not UTF-8 when there are multiple figures in a code chunk, their labels should be different; this should fix https://stackoverflow.com/q/53880195/559676 don't attach the package; use the option `echo` as the example instead of `fig.path` a news item for #1655 close rstudio/rmarkdown#1513: do not warn on encoding if the native encoding is UTF-8 don't show code coverage status since it looks alarming but I don't really care that much state the source of this engine (in case we want to ping the original author in the future) write out the code in UTF-8 don't overprotect users here: if they set the `package` option at all, we assume they have read the documentation merge if-else just signal the error if style is plain wrong, regardless of the chunk option error = TRUE or FALSE use getFromNamespace() instead of get() because get() has a bad default inherits = TRUE, which often causes more trouble than convenience mostly cosmetic changes tweak the news and bump version fix #1675: make fig.show='hide' work for include_graphics() close #1676: add chunk options `class.error`, `class.warning`, and `class.message` to customize the CSS classes for errors, warnings, and messages, respectively use tinytex::latexmk() instead of tools::texi2dvi() to compile tikz graphics fix rstudio/rmarkdown#1538: should rep_len() instead of rep() on labels actually check if the input file is encoded in UTF-8 or not: rstudio/rmarkdown#1513 (comment) pdflatex cannot compile a .tex file if the path is .\foo.tex: https://stackoverflow.com/q/54839403/559676 use basename() to remove the initial .\ unused variables (thanks, RStudio) try to install dvisvgm automatically always stop() if conversion from dvi to svg fails use the magick package instead of ImageMagick to convert pdf figure generated by the tikz engine to other formats factor out tempfile(tmpdir = '.') as wd_tempfile() it seems image_read() cannot read PDF images at least on Windows; so use image_read_pdf() instead, and this will require the pdftools package install libmagick++-dev install libpoppler-cpp-dev for the R package pdftools a news item for #1618 close #1656: clarify on the documentation of opts_current fix #1649: when external = FALSE, use hook_plot_tex() instead of the Markdown plot hook hook_plot_md_base() close #1648: support the chunk option out.extra for include_url() cosmetic don't remove empty lines in purl() add the `encoding` argument back to knit2pandoc() for backward compatibility (this is primarily for the argparse package, which has an Rrst vignette on CRAN compiled through knit2pandoc()) instead of preserving all empty lines like 46826deffbe30815eab2c159dcc17966fca90967, only preserve those not in the beginning or end fix a test on Windows: if the locale is not based on UTF-8, this expression should just return TRUE to avoid an error from assert() a more robust implementation of is_abs_path() use the assert('', {}) syntax there isn't really a good reason to install all soft dependencies point to the blog post https://yihui.name/en/2018/11/biggest-regret-knitr/ Revert "a more robust implementation of is_abs_path()" vectorize is_abs_path() CRAN release v1.22
I also improved this on the |
I believe I am still having this issue. I was able to knit an Rstudio notebook until I added kable tables with kableExtra and now I'm running out of memory. I'm not sure how I should go about making sure that this is the issue. I installed the dev version of knitr and its still happening. Any help would be awesome. |
@Kreitzberg you are most likely seeing a separate issue -- I cannot reproduce the original problem I reported with the development version of knitr. If you can, I would recommend filing a new issue with a reproducible example. (If you cannot create a reproducible example, it is unlikely that your problem will be fixed.) |
Nevermind, I realized I forgot to use head() and was printing large tables! Thanks for your help. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Not sure if this is a bug in
kableExtra
orrmarkdown
, but reporting here for posterity.Created on 2019-02-27 by the reprex package (v0.2.1)
Session info
Note that the
knit_meta_id
attribute grows in size each timerender()
is called. If called enough times, the session will be exhausted of memory. See rstudio/rstudio#2340 for a case where this happens in the wild -- e.g. in R Notebooks, we do callrender()
behind the scenes multiple times in a single session.The main things to note about this bug:
kableExtra
package modifies the.knitEnv$meta
object;rmarkdown::render()
causes that object to explode in size, presumedly from here:rmarkdown/R/render.R
Lines 416 to 423 in bbd0786
I'm not sure if the issue here is that
kableExtra
is doing something it shouldn't, or ifrmarkdown
is not correctly saving / restoring the knit meta object.The text was updated successfully, but these errors were encountered: