memuse is an R package for memory estimation. It has tools for estimating the size of a matrix (that doesn’t exist), showing the size of an existing object in a nicer way than object.size(). It also has tools for showing how much memory the current R process is consuming, how much ram is available on the system, and more.
Originally, this package was an over-engineered solution to a mostly non-existent problem, as a sort of love letter to other needlessly complex programs like the Enterprise Fizzbuzz. However, as of version 2.0-0, I’m sad to report that the package is actually becoming quite useful.
The package has been exhaustively tested on Linux, FreeBSD, Windows, Mac, and “other”-NIX. That is also roughly the platforms in descending order of support for the various operations. However, if you have a problem installing or using the package, please open an issue on the project’s GitHub repository.
Installation
To install the R package, run:
install.package("memuse")
The development version is maintained on GitHub:
remotes::install_github("shinra-dev/memuse")
The C internals, found in memuse/src/meminfo/ are completely separated from the R wrapper code. So if you prefer, you can easily build this as a standalone C shared library.
Package Utilities
The package comes with several classes of utilities. I find all of them very useful during the course of benchmarking, but some are certainly more useful than others.
Memory Lookups
With this package you can get some information about how much memory is physically available on the host machine:
Sys.meminfo()
# Totalram: 15.656 GiB
# Freeram: 10.504 GiB
Sys.meminfo(compact.free=FALSE) ### Linux and FreeBSD only
# Totalram: 15.656 GiB
# Freeram: 1.067 GiB
# Bufferram: 1.332 GiB
# Cachedram: 8.207 GiB
Sys.swapinfo() ## same as Sys.pageinfo()
# Totalswap: 32.596 GiB
# Freeswap: 32.595 GiB
# Cachedswap: 444.000 KiB
You can find the ram usage of the current R process:
memuse
memuse is an R package for memory estimation. It has tools for estimating the size of a matrix (that doesn’t exist), showing the size of an existing object in a nicer way than
object.size(). It also has tools for showing how much memory the current R process is consuming, how much ram is available on the system, and more.Originally, this package was an over-engineered solution to a mostly non-existent problem, as a sort of love letter to other needlessly complex programs like the Enterprise Fizzbuzz. However, as of version 2.0-0, I’m sad to report that the package is actually becoming quite useful.
The package has been exhaustively tested on Linux, FreeBSD, Windows, Mac, and “other”-NIX. That is also roughly the platforms in descending order of support for the various operations. However, if you have a problem installing or using the package, please open an issue on the project’s GitHub repository.
Installation
To install the R package, run:
The development version is maintained on GitHub:
The C internals, found in
memuse/src/meminfo/are completely separated from the R wrapper code. So if you prefer, you can easily build this as a standalone C shared library.Package Utilities
The package comes with several classes of utilities. I find all of them very useful during the course of benchmarking, but some are certainly more useful than others.
Memory Lookups
With this package you can get some information about how much memory is physically available on the host machine:
You can find the ram usage of the current R process:
Also, if you’re working close to the metal, you may be interested in seeing how large the CPU caches are and/or how big the cache linesize is:
Estimating Memory Usage
You can estimate memory storage requirements of a matrix without having to divide by some annoying power of 2:
Alternatively, given a (memory) size, you can also find the dimensions of such a matrix:
For more information, see the package vignette.
Misc
The package also has some miscellaneous helpful utilities:
Authors
memuse is authored and maintained by:
With additional contributions from: