After answering about tracemem recently, I learned about retracemem. The help for ?retracemem and the example therein leave me unenlightened.
What does retracemem actually do and why? It doesn’t do what I thought it would do, i.e. point one object to the memory location of another, at least as far as I can tell.
I tried a wizardly invocation like .Internal(inspect()), which performs no magic for me:
> a = 1:10
> b = a[-1]
> .Internal(inspect(a))
@00000000087AE578 13 INTSXP g0c4 [NAM(2)] (len=10, tl=23336) 1,2,3,4,5,...
> .Internal(inspect(b))
@00000000087AE8E8 13 INTSXP g0c4 [NAM(2)] (len=9, tl=7208) 2,3,4,5,6,...
> retracemem(b,retracemem(a))
> .Internal(inspect(b))
@00000000087AE8E8 13 INTSXP g0c4 [NAM(2)] (len=9, tl=7208) 2,3,4,5,6,...
I think
retracemem()just lets you tag a variable copy, which wouldn’t produce a tracemem statement (such as ababove which is really just a copy ofasans the first element), as being derived from the same source variable, so you can continue to watch the copies/partial copies propagate and see that they derive from the same source.For example, how does A’s memory get copied/propagated:
But then again, I could be entirely wrong…