set ns [new Simulator]
for {set i 0} {$i \< 500} {incr i} {
set a [new RandomVariable/Constant]
}
One would expect that the memory usage should stay the same after the
first RandomVariable is allocated. However, because OTcl does not have
garbage collection, when the second RandomVariable is allocated, the
previous one is not freed and hence results in memory leak. Unfortunately,
there is no easy fix for this, because garbage collection of allocated
objects is essentially incompatible with the spirit of Tcl. The only way
to fix this now is to always explicitly free every allocated OTcl object
in your script, in the same way that you take care of malloc-ed object in
C/C++.