Fungsi ini menandai suatu objek sehingga pesan dicetak setiap kali kode internal menyalin objek tersebut. Ini adalah penyebab utama penggunaan memori yang sulit diprediksi di R.
tracemem(x)
untracemem(x)
retracemem(x, previous = NULL)
| Parameter | Deskripsi |
|---|---|
x |
An R object, not a function or environment or NULL. |
previous |
A value as returned by tracemem or retracemem. |
# NOT RUN {
a <- 1:10
tracemem(a)
## b and a share memory
b <- a
b[1] <- 1
untracemem(a)
## copying in lm: less than R <= 2.15.0
d <- stats::rnorm(10)
tracemem(d)
lm(d ~ a+log(b))
## f is not a copy and is not traced
f <- d[-1]
f+1
## indicate that f should be traced as a copy of d
retracemem(f, retracemem(d))
f+1
# }