From: John Woods Date: 2008-02-22T07:36:53+09:00 Subject: Re: Newbie Mem Leak Issue >> Array.new(1000000) {str} Isn't the above still just an array of 1000000 refs to the same string? Perhaps you meant str.dup? For example: irb> str = "asdf" irb> puts Array.new(3){str}.collect{|s|s.object_id} -605717778 -605717778 -605717778 # the above three object_ids are the same irb> puts Array.new(3){str.dup}.collect{|s|s.object_id} -605741458 -605741468 -605741478 # the above three object_ids are different -----Original Message----- From: Keith Barr Sent: 02/21/2008 02:16 PM > Joel VanderWerf wrote: >> Keith Barr wrote: >>> str = "0123456789 0123456789 0123456789 0123456789 0123456789 >>> 0123456789 0123456789 0123456789 0123456789 0123456789 " >>> @huge_mem = Array.new(1000000, str) >> That's an array of 1000000 references to the same string. Did you want >> lots of strings? This is the way to do that: >> >> Array.new(1000000) {str} >> >> ------------------------------------------------------------- Array::new >> Array.new(size=0, obj=nil) >> Array.new(array) >> Array.new(size) {|index| block } > > oops, yeah, good catch.