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