Moving memory blocks and updating references

Discussion in 'C++' started by HeroOfSpielburg, Aug 12, 2003.

  1. hi, I know this is a much-travelled subject, but I was wondering what
    people's thoughts were on the bare minimum (and conversely the grand
    scheme) for augmenting standard memory references to handle moving
    objects around in memory (as is needed in compaction algorithms
    associated with 'moving collection' aka 'copy collection').

    There are a number of ways to handle this without affecting the
    overarching structure of one's program (albeit naive or brute force),
    like overloading 'dumb' pointer operators so assignments and copies
    invoke the storing of the new reference in a big table. Thusly when a
    move is performed on data starting at pointer X, X's references are
    extracted from the table and the new location is updated for each of
    those references.

    A second approach I've seen is creating redirecting 'detour' pointers
    that point to the new location after the move. I'm not sure I
    completely understand how this works, but topically it seems to make a
    mess of memory by leaving these little 4-byte (uint ~= void*) 'bread
    crumbs' all over the place.

    The most frequent tactics I've seen mentioned are the use of smart
    and/or master pointers (possibly evolving to handles). Is this the
    best way? It seems like a substantial investment for having to change
    the way everything in the existing codebase handles memory references
    (not to mention if 3rd party libraries sneak around it), and I'm not
    100% sure I understand how it makes moving objects possible (and
    easier?).

    If memory gurus can impart their thoughts on the pro and con of
    various approaches used to facilitate moving blocks of memory with
    existing references in the client application, I'd be much obliged.

    Thanks for the help!
     
    HeroOfSpielburg, Aug 12, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arjen
    Replies:
    3
    Views:
    449
    Scott Allen
    Feb 27, 2005
  2. Roger Leigh
    Replies:
    8
    Views:
    446
    Karl Heinz Buchegger
    Nov 17, 2003
  3. news.rcn.com
    Replies:
    2
    Views:
    1,127
    Roedy Green
    Dec 10, 2007
  4. matt
    Replies:
    1
    Views:
    275
    George Ogata
    Aug 6, 2004
  5. Steven Taylor
    Replies:
    9
    Views:
    256
    Brian Candler
    Apr 27, 2009
Loading...

Share This Page