Objectives

Upon completion of this lesson, you will be able to:

  • tbd

Overview

Memory in R

R, at the present, uses a static memory model. This means that when R starts up, it asks the operating system to reserve a fixed amount of memory for its use. The size of this block of memory cannot be changed once R starts. Therefore, it can happen that not enough memory was allocated, e.g., when trying to read large data sets into R.

Virtual Memory Translation

Memory Translation
Memory Translation

Program Managed Memory

pm.page.size <- 1024
pm.num.pages <- 4 * 1024
pm.memsize <- pm.num.pages * pm.page.size

# free any prior memory to avoid memory leaks or garbage collection
rm(list = c("pm.mem","free.blocks"))

# allocate block of contiguous memory
pm.mem <- vector(mode = "character", length = pm.memsize)

# divide memory into 1k pages and create table of free pages
free.blocks <- data.frame(page.num = integer(pm.num.pages),
                          is.used = logical(pm.num.pages))

free.blocks$page.num <- 1:pm.num.pages
pm.alloc <- function (n.bytes)
{
  
}

Acknowledgement

This lesson is based on work by Desnoyers, Peter (Fall 2020). How Operating Systems Work, Fall 2020 Edition, Northeastern University, that is provided under Creative Commons License 4.0.

References

Desnoyers, Peter (Fall 2020). How Operating Systems Work, Fall 2020 Edition, Northeastern University. Creative Commons License 4.0.

Wickham, H. (n.d.). Advanced R: Memory

Errata

None collected yet. Let us know.