RStudio lag and high memory usage by RStudio (not R session)

Hi there. Lately when I've been running RStudio, after a while there starts to be significant lag in terms of running a cell, and over time the RStudio process (not the R session process) consumes gigabytes of memory (see image below). There is no typing lag, but if I click the play button on a chunk, or do Ctrl+Enter or Ctrl+Shift+Enter, it may take 10-20 seconds for the code to actually go into the console and run. I'm not sure what's changed, but maybe you can help me debug it?

More information: I'm running R 3.6.3 (x64), RStudio 1.4.1106, and am on Windows 10. This happens in both R Notebooks and in R Markdown-- basically, whenever I'm running a chunk and there is output in the notebook already. Lately I've been working inside R Projects. I've tried reinstalling RStudio, but that didn't help.

Thanks in advance for your help!


I think I solved my own question! I tried deleting the .Rproj.user folder (after closing RStudio), and once I did that, RStudio got very snappy again! It seems like that folder can get corrupted somehow? I found this solution when I stumbled on this post: RStudio Desktop unresponsive in project

So, hopefully this post might amplify this solution for others who encounter it.

It turns out I was wrong! I think the real reason for the slowdown was that I was working in an R Notebook, and every time it saved, it was re-rendering the HTML, which took longer for larger R Notebooks. So when I'd try to run something, if it was still rendering from the last time, it would have to wait until that was done to re-run.

Removing the line "output: html_notebook" fixed that. You can still knit to HTML if you want, so there's no loss there.