Learn R Programming

fritools (version 3.3.0)

memory_hogs: Find Memory Hogs

Description

List objects in an R environment by size.

Usage

memory_hogs(
  unit = c("b", "Kb", "Mb", "Gb", "Tb", "Pb"),
  return_numeric = TRUE,
  ...,
  envir = .GlobalEnv
)

Arguments

unit

The unit to use.

return_numeric

Return a numeric vector? If set to FALSE, a character vector including the unit will be returned, which might be less usable but easier to read.

...

Arguments passed to order, defaults to decreasing = FALSE.

envir

The environment where to look for objects.

Value

A named vector of memory usages.

See Also

Other R memory functions: wipe_clean()

Examples

Run this code
# NOT RUN {
va <- rep(mtcars, 1)
vb <- rep(mtcars, 1000)
vc <- rep(mtcars, 2000)
vd <- rep(mtcars, 100)
memory_hogs()
memory_hogs(unit = "Mb", decreasing = TRUE)
memory_hogs(unit = "Mb", decreasing = TRUE, return_numeric = FALSE)
# }
# NOT RUN {
# remove the two largest objects:
rm(list = names(tail(memory_hogs(decreasing = FALSE), n = 2)))
memory_hogs(unit = "Mb")
# }

Run the code above in your browser using DataLab