Run the following within an AOLServer process, and you'll notice your free
memory dwindle:

  set n 1000
  set o 500
  for {set i 0} {$i < $o} {incr i} {
    for {set j 0} {$j < $n} {incr j} {
      set myArray${i}_${j}(foo${j}) bar{$j}
    }
  }

The thread that runs this block loses all references to the arrays you
created, yet the memory taken up by your process grows substantially...

In fact you can run the following code in either AOLServer or tclsh, and
you'll see the same effect:

  set n 1000
  set o 500
  for {set i 0} {$i < $o} {incr i} {
    for {set j 0} {$j < $n} {incr j} {
      set myArray${i}_${j}(foo${j}) bar{$j}
    }
  }
  for {set i 0} {$i < $o} {incr i} {
    for {set j 0} {$j < $n} {incr j} {
      unset myArray${i}_${j}
    }
  }

What gives?  Is this a memory leak in tcl itself, is the garbage collector
simply slow to react, or is there something else?

-T

Reply via email to