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

View source: R/releaseViews.R

releaseViewsR Documentation

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)

Arguments

namespace

string of the identifier of the shared memory context.

variableNames

A character vector of variable names to delete.

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.

Value

No return value, called for deallocation of views.

Author(s)

Julian Maerte

See Also

retrieveViews, registerVariables

Examples

  ## Not run: 
  # MASTER SESSION:
  # allocate data
  
## End(Not run)
  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))
  ## Not run: 
  # WORKER SESSION:
  
## End(Not run)
  res = retrieveViews(namespace, c("mat", "y"))
  ## Not run: 
  # Perform your shared calculations here
  
## End(Not run)
  releaseViews(namespace, c("mat", "y"))
  ## Not run: 
  # MASTER SESSION:
  # free memory
  
## End(Not run)
  memshare::releaseVariables(namespace, c("mat", "y"))

memshare documentation built on Dec. 5, 2025, 9:07 a.m.