From: "ara.t.howard" Date: 2007-07-22T12:14:51+09:00 Subject: Re: Array flatten memory "leak"? On Jul 21, 2007, at 6:08 PM, Ron M wrote: > But the strange (to me) thing is that is that the next loop - > which seems like it shouldn't be allocating more memory since > nothing gets saved to variables - where the program quickly > grows to over 200MB but assigning to variables isn't what determines whether memory is used, it's a simple matter of object creation: cfp:~ > cat a.rb #! /usr/bin/env ruby STDOUT.sync = true require 'yaml' def n_objects n = 0 and ObjectSpace.each_object{ n += 1 } n end y 'n_objects_0' => n_objects 65635.times{ "foo" } y 'n_objects_1' => n_objects GC.start y 'n_objects_2' => n_objects cfp:~ > ruby a.rb --- n_objects_0: 2599 --- n_objects_1: 28143 --- n_objects_2: 1648 if it were then n_objects_1 wouldn't show such a huge increase: we've assigned no variables here. my point is that what is important is object creation and when those objects get freed by the GC. regards. a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama