On 9/5/06, Bob Hutchison <hutch / recursive.ca> wrote:
> I've attached a trivial script that demonstrates on OS X and likely
> linux (unlikely windows because of the ps stuff) the problem. To see

This is 'windows' version, using pslist[1]
And, yes, it does the same under windows as well.

Jano

[1] http://www.sysinternals.com/Utilities/PsList.html

$VERBOSE = nil
STDOUT.sync = true
trap('INT'){ exit }

fixit = 0 < ARGV.size

m = 1000000
n = 1000

all_arrays = []
first = true

n.times do |i|
  if 0 < m then
    a = ["x" * m ]
    all_arrays << a
    a[0] = nil if fixit and 0 < a.size
    a.shift
  else
    a = []
    all_arrays << a
  end

  if 0 == (all_arrays.size % 10) then
    GC.start
    stdout = `pslist -m #{ Process.pid }`
    stdout = stdout.split(%r/\n/)
    if first then
      printf("\n         %s\n", stdout[7])
      first = false
    end
    printf("%6d:: %s\n", all_arrays.size, stdout.last)
  end
end