From: "ara.t.howard" Date: 2008-09-11T04:23:50+09:00 Subject: Re: How to operate on 2 arrays simultaneously? On Sep 10, 2008, at 1:03 PM, matt neuburg wrote: > Everything in Ruby is a pointer. If a[0] is a pointer to a "big long > string", then a.zip(b)[0][0] is a pointer to the very same "big long > string" - not a copy of the string. So creating the "huge_new_array" > just creates some new pointers, right? And pointers are very small. So > for huge_new_array to be a problem, the existence of a and b would > have > to have been problematic to start with - meaning that they would > have to > have huge length. The amount of *data* in the story (stuff like "big > long string") is not increased. not really cfp:~ > cat a.rb mb = 2 ** 20 big = 2 * mb a = Array.new big b = a.dup memory_usage = `ps -o rss= -p #{Process.pid}`.to_i puts memory_usage a.zip(b) memory_usage = `ps -o rss= -p #{Process.pid}`.to_i puts memory_usage cfp:~ > ruby a.rb 9616 99104 a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama