Reference counting and tracing are two alternative approaches to [garbage collection]. ** Language examples ** *** Languages that use reference counting *** * [Perl] * [Tcl] *** Languages that use a tracing GC *** * [Java] *** Languages that use a combination of both *** * [Jim Tcl] (uses a tracing GC for `[Jim References%|%ref]`s) * [Python] (uses a tracing GC for cycle detection) ** Discussion ** [DKF] 2015-08-02: Tcl uses reference counting, and can largely get away with it because it has no reference loops. If you try to put a value inside itself (e.g., with [lset] or [dict set]) the value gets duplicated (because of copy-on-write) and the container becomes the new value. This does depend on the model-immutability of Tcl's value system though, and is the reason why we tend to be ''very'' strict on maintaining that model: merely ''allowing'' reference loops would ''require'' us to change our memory management system. There are advantages to using reference counting, of course. In particular, it allows us to integrate with C libraries relatively easily and it is typically parsimonious in its memory use (though we cede some of that for greater thread performance). Garbage collection, while potentially faster, has greater memory overheads and higher impedance with C. ** See also ** * [http://lambda-the-ultimate.org/node/4155%|%Lambda the Ultimate discussion] <>Concept