Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.



Wanted-alive tag for objects

Indicate whether any object particularly 'wants' another object
  [vote for,

In a garbage-collection-based object memory manager (e.g. Microsoft's .net), certain objects will remain in memory as long as a program is running; they are always considered "live". Other objects are live if live object has a reference to them. If no live object holds a reference to an object, it is subject to being declared "dead" and consequently deleted.

One difficulty with this approach is that some objects may maintain references to other objects for the purpose of updating them in ways that live objects may care about. If such a former object could tell that no live objects were interested in the updates it was doing to a particular object, it could drop all references to that object, thus allowing its deletion (and avoiding useless updates).

Microsoft .net provides a "WeakReference" type which achieves some of this functionality. An object can hold a weak reference to another object; any time the only existing references to an object are weak ones, the object may subject to deletion.

One difficulty with this approach is that in order to actually do anything with a WeakReference, an object must generate a strong reference to it. If the system happens to do its "live reference check" while the strong reference is held, it will conclude that the object is still useful and thus not eligible for deletion. Thus, the object may continue to receive updates long after it has become useless.

My idea would be a 'wanted alive' bit in object references which would indicate whether the holder of the reference wants the object kept around on its behalf, and a similar bit in each object descriptor to indicate whether any reference has the 'wanted alive' bit set. If none of the references have the 'wanted alive' bit set, the corresponding bit would be cleared in the descriptor. That bit would then be a signal to allow other objects to drop their references at their convenience.

While this may not be of particular importance in present systems (the .net WeakReference type works pretty well) it could become important if future systems attempt to perform garbage collection concurrent with other operations.

supercat, Jul 26 2008


       I suspect the problem with MS is far more profound then a simple "misunderstanding" about what programs are still in use on the computer.
WcW, Jul 26 2008


back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle