By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,905 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,905 IT Pros & Developers. It's quick & easy.

Moving memory blocks and updating references

P: n/a
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

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!
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.