Increasing (or decreasing) the memory available to R processes

后端 未结 6 1054
你的背包
你的背包 2020-11-22 12:52

I would like to increase (or decrease) the amount of memory available to R. What are the methods for achieving this?

相关标签:
6条回答
  • 2020-11-22 13:32

    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).

    0 讨论(0)
  • 2020-11-22 13:32
    1. Buy more ram
    2. Switch to a 64-bit OS. Combine with point 1.
    0 讨论(0)
  • 2020-11-22 13:38

    Use memory.limit(). You can increase the default using this command, memory.limit(size=2500), where the size is in MB. You need to be using 64-bit in order to take real advantage of this.

    One other suggestion is to use memory efficient objects wherever possible: for instance, use a matrix instead of a data.frame.

    0 讨论(0)
  • 2020-11-22 13:46

    To increase the amount of memory allocated to R you can use memory.limit

    memory.limit(size = ...)
    

    Or

    memory.size(max = ...)
    

    About the arguments

    • size - numeric. If NA report the memory limit, otherwise request a new limit, in Mb. Only values of up to 4095 are allowed on 32-bit R builds, but see ‘Details’.
    • max - logical. If TRUE the maximum amount of memory obtained from the OS is reported, if FALSE the amount currently in use, if NA the memory limit.
    0 讨论(0)
  • 2020-11-22 13:48

    In RStudio, to increase:

    file.edit(file.path("~", ".Rprofile"))
    

    then in .Rprofile type this and save

    invisible(utils::memory.limit(size = 60000))
    

    To decrease: open .Rprofile

    invisible(utils::memory.limit(size = 30000))
    

    save and restart RStudio.

    0 讨论(0)
  • 2020-11-22 13:51

    Microsoft Windows accepts any memory request from processes if it could be done.

    There is no limit for the memory that can be provided to a process, except the Virtual Memory Size.

    Virtual Memory Size is 4GB in 32bit systems for any processes, no matter how many applications you are running. Any processes can allocate up to 4GB memory in 32bit systems.

    In practice, Windows automatically allocates some parts of allocated memory from RAM or page-file depending on processes requests and paging file mechanism.

    But another limit is the size of paging file. If you have a small paging-file, you cannot allocated large memories. You could increase the size of paging file according to Microsoft to have more memory space.

    0 讨论(0)
提交回复
热议问题