memory: Check the total and free memory in the OS

Description Usage Arguments Value Author(s) Examples

Description

This is a function that checks the total amount of memory on the system, and also the amount that is not used (free memory). This uses the commands from operating system, and would be useful to check an object with what size can be fitted in memory.

The additional arguments:

echo: logical (default echo=TRUE), specifies whether the output (with size unit) should be printed on screen (e.g., "16 Gb").

session: logical (default session=FALSE), if TRUE, the memory used by the current session is also reported.

.r: numeric (default .r=5), the decimal degrees to which the output values are rounded.

Usage

1
  memory(u, ...)

Arguments

u

a character specifying the memory size unit; can be one of 'B', 'K', 'M' (default), 'G', 'T', for Byte, Kilo-B, Mega-B, Giga-B, and Terra-B respectivey

...

additional arguments (see details)

Value

a numeric vector with two items including the size of total and free memory. If session=T, an additional item (used_by_this_session) is included as well.

Author(s)

Babak Naimi naimi.b@gmail.com

http://r-gis.net

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
memory()

m <- memory(u='G') # by default, the report is printed on screen, but a numeric vector is returned

m

m <- memory(u='G', echo=FALSE) # the report is not printed on screen

m

memory(session=TRUE) # the size of memory used by the current session is also included

# unit in Tb (Terra byte):
memory(u='T',session=TRUE, .r=4) # the values are rounded to 4 decimals.

memory(u='G',session=TRUE, .r=NULL) # the values are returned without any round!

babaknaimi/mraster documentation built on May 28, 2019, 2:34 a.m.