A Garbage Collection Caveat: Circular References

One important caveat applies to garbage collection of both basic types and objects. The steve garbage collection scheme does not correctly deallocate memory when there are circular references. A circular reference occurs when two (or more) objects refer to each other in a circular fashion. An example of a circular reference between three objects is shown below:

When a circular reference occurs, the objects are never recognized as "unused" and are thus never deleted as they should be. Circular references thus lead to "islands" of unused memory which do not get released. This type of circular reference is rare, but if your simulation design makes use of these types of structures, you may have to explicitly overwrite variables in order to ensure that no circular references exist.