How to check the amount of RAM in R

后端 未结 3 845
一向
一向 2020-12-15 15:38

I want to make a function that imports data in different numbers of batches depending on how much RAM is available on someones system. But how can I find the amount of avail

相关标签:
3条回答
  • 2020-12-15 15:49

    Given the warnings concerning platform-dependency discussed in the earlier comment, you could for example parse /proc/meminfo on Linux:

    $ grep MemFree /proc/meminfo 
    MemFree:          573660 kB
    $ awk '/MemFree/ {print $2}' /proc/meminfo 
    565464
    

    You could try the second approach via system(..., intern=TRUE), or even via a pipe connection.

    Edit some 5+ years later: In R, and just following what the previous paragraph hinted at:

    R> memfree <- as.numeric(system("awk '/MemFree/ {print $2}' /proc/meminfo", 
    +                               intern=TRUE))
    R> memfree
    [1] 3342480
    R> 
    
    0 讨论(0)
  • 2020-12-15 15:51

    Now you can do that with benchmarkme::get_ram function.

    https://cran.r-project.org/web/packages/benchmarkme/benchmarkme.pdf

    0 讨论(0)
  • 2020-12-15 15:54

    I would recommend using memuse::Sys.meminfo().

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