Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6529023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:35:24+00:00 2026-05-25T09:35:24+00:00

After answering about tracemem recently , I learned about retracemem . The help for

  • 0

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,...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:35:25+00:00Added an answer on May 25, 2026 at 9:35 am

    I think retracemem() just lets you tag a variable copy, which wouldn’t produce a tracemem statement (such as a b above which is really just a copy of a sans 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:

    > A <- 1:10
    > tracemem(A)
    [1] "<0x100a2a978>"
    > B <- A                                # Assignment to B doesn't make copy
    > C <- A + 1                            # Assignment to C makes copy, alters it
    tracemem[0x100a2a978 -> 0x1020ebbf0]: 
    > D <- C + 1                            # Assignment to D makes copy, alters it
    tracemem[0x1020ebbf0 -> 0x1020ebc98]: 
    > E <- B + 1                            # Assignment to E makes copy, alters it
    tracemem[0x100a2a978 -> 0x1020a4208]: 
    > F <- A[-1]                            # Assignment to F doesn't make copy?
    > G <- F + 1                            # Even after altering it?
    > retracemem(F, retracemem(A))          # Hint to R that F is really A derived
    tracemem[<0x100a2a978> -> 0x1009c5910]: 
    > G <- F + 1                            # Reassignment to G makes copy, alters it
    tracemem[0x1009c5910 -> 0x1020a4748]: 
    

    But then again, I could be entirely wrong…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After answering a question about how to force-free objects in Java (the guy was
After recently answering a couple of questions here on SO that involved utilizing PHP's
After reading a bit more about how Gnutella and other P2P networks function, I
The question plot (a bit abstract, but answering this question will help me in
After answering this question and not finding a satisfying answer in the standard paper,
After answering this question I am left wondering why removeChild needs a parent element.
After answering this question I was trying to find is_complete template in Boost library
I recently botched a job interview by poorly answering a straightforward question: how do
After answering this question I put together the following C# code just for fun:
After answering to that SO question and being donwvoted I'd like to check something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.