From: "Aleksi Niemelä" Date: 2000-12-16T07:48:36+09:00 Subject: [ruby-talk:7360] Re: Ruby performance question Eric Crampton reports: > > > Running on a small dataset of 13 MB of data (around 81000 > > > lines), the > Incidently, I tried disabling GC and running it on my small dataset > (13 MB) which I would think would fit in physical memory. Somehow, the > way Ruby is organizing data in memory causes it to store far, far, far > more than 13 MB. I ran out of physical memory (1 GB of RAM) and it > went into swap. :-( No wonder, although I can't show any math to back me up (I'm shamed of my poor skills :). > while line = $stdin.gets.chomp! > line.split(",").each { |f| > fid, val = f.split("=") > h[fid] = val > } But there will be (at least) 81 000 times an array creation of 81 000 * avg_pair_count_on_line created strings. Then each of those strings create yet again an array which is filled with two created strings. We shouldn't discard strings created by gets either. I don't know if there's something more. - Aleksi