Forcing R (and Rstudio) to use the virtual memory on Windows
In order to get it working automatically every time you start RStudio the solution with R_MAX_MEM_SIZE is ignored, both if created as an environment variable or if created inside the .Rprofile.
Writing memory.limit(64000) is ignored too.
The proper way is adding the following line in the file .Rprofile
invisible(utils::memory.limit(64000))
or whatever number you want.
Of course you need to have a pagefile big enough. That number includes free RAM and free pagefile space.
Using the pagefile is slower but it's going to be used only when needed.
Something strange I've found is that it only let's you increase the maximum memory to use but it doesn't allow you to decrease it.
Stop before RAM-swap to disk
On Linux / MAC OSX:
installed.RAM <- as.numeric(system("awk '/MemTotal/ {print $2}' /proc/meminfo",intern=TRUE));
used.RAM <- installed.RAM - as.numeric(system("awk '/MemFree/ {print $2}' /proc/meminfo", intern=TRUE));
Increasing (or decreasing) the memory available to R processes
From:
http://gking.harvard.edu/zelig/docs/How_do_I2.html (mirror)
Windows users may get the error that R
has run out of memory.If you have R already installed and
subsequently install more RAM, you may
have to reinstall R in order to take
advantage of the additional capacity.You may also set the amount of
available memory manually. Close R,
then right-click on your R program
icon (the icon on your desktop or in
your programs directory). Select
``Properties'', and then select the
``Shortcut'' tab. Look for the
``Target'' field and after the closing
quotes around the location of the R
executible, add--max-mem-size=500M
as shown in the figure below. You may
increase this value up to 2GB or the
maximum amount of physical RAM you
have installed.If you get the error that R cannot
allocate a vector of length x, close
out of R and add the following line to
the ``Target'' field:--max-vsize=500M
or as appropriate. You can always
check to see how much memory R has
available by typing at the R prompt
memory.limit()
which gives you the amount of available memory in MB. In previous versions of R you needed to use: round(memory.limit()/2^20, 2)
.
Related Topics
How to Run Lm Regression for Every Column in R
Sources on S4 Objects, Methods and Programming in R
Remove Rows Where All Variables Are Na Using Dplyr
Mgcv: How to Set Number And/Or Locations of Knots for Splines
Shiny - Can Dynamically Generated Buttons Act as Trigger for an Event
Could Not Find Function Inside Foreach Loop
Daily Time Series with Ts.. How to Specify Start and End
Meaning of Objects Being Masked by the Global Environment
How to Pass Input Variable to SQL Statement in R Shiny
How to Play Birthday Music Using R
In Ggplot2, How to Add Additional Legend
Generating a Vector of Difference Between Two Vectors
Forcing R (And Rstudio) to Use the Virtual Memory on Windows