Learn R Programming

memshare (version 1.1.0)

releaseViews: Function to release views of a shared memory space.

Description

Given a namespace identifier (identifies the shared memory space to register to), this function releases retrieved views from the shared memory space.

NOTE: All views have to be free'd upon releasing the variable by the master.

Usage

releaseViews(namespace, variableNames)

Value

No return value, called for deallocation of views.

Arguments

namespace

string of the identifier of the shared memory context.

variableNames

A character vector of variable names to delete.

Author

Julian Maerte

Details

This is the only way to drop handles created by retrieveViews. Wrappers such as memApply / memLapply call this function internaly. Not releasing views effectively leaks the backing pages for the lifetime of the process.

See Also

retrieveViews, registerVariables

Examples

Run this code
  if (FALSE) {
  # MASTER SESSION:
  # allocate data
  }
  n = 1000
  m = 100

  mat = matrix(rnorm(n * m), n, m) # target matrix
  y = rnorm(n) # some other constant vector in which the function should not run

  namespace = "ns_relview"
  memshare::registerVariables(namespace, list(mat=mat, y=y))
  if (FALSE) {
  # WORKER SESSION:
  }
  res = retrieveViews(namespace, c("mat", "y"))
  if (FALSE) {
  # Perform your shared calculations here
  }
  releaseViews(namespace, c("mat", "y"))
  if (FALSE) {
  # MASTER SESSION:
  # free memory
  }
  memshare::releaseVariables(namespace, c("mat", "y"))

Run the code above in your browser using DataLab