From: MonkeeSage Date: 2007-11-26T18:05:04+09:00 Subject: Re: specify start postion of Regexp matching Here's a test to show that my reading of the source, and Robert's assertion, is correct (there is probably a better way to do this...): #!/usr/bin/env ruby # disable GC to get fair reading of actual allocation cost GC.disable def free_megs (`free -o`.split("\n")[1].split(' ')[3].to_i/1024).to_s end puts "Free megabytes " + free_megs # make a one megabyte string s1 = "a" * 1048576 s100 = "" # placeholder to be filled in below # make 100 substrings of it 0.upto(101) { |i| eval("s#{i}=s1[0..-1]") } puts s100.length.to_s puts "Free megabytes " + free_megs Output: Free megabytes 588 1048576 Free megabytes 587 Only one meg is used, which is the length of the original string. So, by inductive inference, the substrings are only pointers back to the original string rather than copies of the data. Regards, Jordan