Memory Management and Garbage Collection of Objects

breve's garbage collection is slightly complicated by the fact that objects do not need to be referenced in memory to be "in use". An unreferened object may, for example, "come back to life" because of an all ([link]) expression. Furthermore, objects in the simulated world (members of subclasses of the class "Real") may physically interact even without referencing each other in their variables. Because of these complications, garbage collection cannot be automatically enabled for all objects in a simulation.

Garbage collection for objects is thus enabled on a per-object basis and the programmer must decide when its use is appropriate. The following guidelines should generally help to decide when garbage collection is appropriate for an object:

  • the object is not a member of a subclass of Real.

  • the object does not have it's own iterate or post-iterate methods.

  • the object is not a dependency of any object that does not hold a reference to it.