© copyright 1997,1998,1999,2000,2001 John M McIntosh, all rights reserved. Page 43
Weak Objects - VW Examples
*(1) Symbols are unique, but how?
-The class Symbol has a class variable that contains an array of WeakArrays, defining all symbols in the image.
-If you create a new symbol, it is hashed into one of the WeakArrays. If you refer to an existing symbol, the compiler finds the reference to the symbol in the WeakArray which is what the methodcontext points to.
-If you delete the method containing the symbol, it might be the last strong reference to that symbol! If this is true, at some point the symbol is garbage collected, and finalization takes place. This puts a zero into the WeakArray slot, and that symbol disappears from your image! Thus method removal doesn’t require symbol table maintenance, it happens as part of the Weak array logic.
*(2) VW ObjectMemory used finalization to signal when a scavenge event has happened (in 2.5x, not 5.x).