| Description: |
test_dict_basic_self_reference checks whether a dictionary with a first level self-references is
correctly destructed.
In SLI dictionaries are reference counted objects. Copying a dictionary means copying the pointer
and providing another reference to the same object. If the contents of the dictionary is changed,
the object remains the same and the change is visible from all references to the object. This behavior
is unlike the behavior of arrays which are also reference counted but are immediately cloned if the
contents is changed via one of the references. Therefore the change to an array from one reference
is never visible from other potential references. The behavior of arrays is sometimes called "lazy copy".
As a consequence of these definitions, dictionaries may contain references to themselves which we call
self references. When a dictionary is destroyed special care needs to be taken to handle the self references
correctly. Revisions of NEST prior to r10990 where not handling this correctly and causing a memory
leak. The memory leak can be exposed by the following lines
ulimit -v $((1024*1024))
SLI ] {<< /d 0 >> dup begin /d exch def end} loop
which quickly exhausts the provided memory. This demonstration of the memory leak was provided by
Alexander Peyser in April 2014. It is possible that early versions of the SLI interpreter contained
code to handle recursive dictionary definitions which got lost over the years.
|