The ooRexx garbage collector is partially generational. All of the objects contained in the flattened rexx.img file are restored into a separate object space and given a special mark ("OldSpace") that indicates these objects are never to be garbage collected. They are also not traced during a garbage collection cycle, which can cause a problem if a reference to an object residing in the normal object heap is ever stored in a field of an oldspace object. Without special attention, these objects could end up getting garbage collected inappropriately.
To solve this problem, the OrefSet macro is used to detect the situation where a new space object is being stored in an oldspace object. This implements a write barrier that detects that situation and adds the object to a special table that tracks all references from the oldspace to the newspace. The reference count is a counter of how many references we have. The OrefSet barrier also detects if the field being written into crosses that barrier so that the reference counts can be decremented. OrefSet is necessary for setting any reference field in a class that might get stored in the saved image. Classes that don't implement this properly can result in some very nasty (and hard to debug) garbage collection problems. Generally, it is good practice to use OrefSet whenever you are setting an object reference. The one exclusion are any of the classes in the <Transient> grouping in PrimitiveClasses.xml. These are classes that represent runtime state, and will never be stored in the image file. These classes are permitted to just directly assign the fields without requiring OrefSet(). That is the only exception, but you need to understand the situation when deciding not to use OrefSet(). If not certain of whether it is required, then use it, since it is never an error to use it, but it might be an error to omit it. Rick On Tue, Jun 30, 2009 at 8:38 AM, Moritz Hoffmann<antig...@gmail.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all, > I have been browsing through the ooRexx source code and came to some > point where RexxMemory::setOref() is called. I think this was from > whithin the macro OrefSet. > > It would be nice if someone could explain what the method does! I see > that it maintains some reference count. What is this used for? I though > thought the ooRexx reference handling and object deallocation was based > on reachability, and not on reference counting...? > > Thanks in advance, > Moritz > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkpKB0wACgkQl56sB+DIUZS5pwCdEE3rFwz71XnE8QO54PZUDU1v > VIAAn0zkxylBt1jmWPWaT6WJ3iXLgMnr > =W9Ni > -----END PGP SIGNATURE----- > > ------------------------------------------------------------------------------ > _______________________________________________ > Oorexx-devel mailing list > Oorexx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > ------------------------------------------------------------------------------ _______________________________________________ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel