Moving memory blocks and updating references

H

HeroOfSpielburg

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top