From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-01-16T05:13:55+09:00 Subject: Re: memory usage question In article , Mark Hahn wrote: > >I was running under cygwin, but got a decent error message and no crash. > >That is good news that it is probably not an inherent Ruby problem. > >-----Original Message----- >From: Bill Kelly [mailto:billk@cts.com] >Sent: Tuesday, January 15, 2002 11:12 AM >To: ruby-talk ML >Subject: Re: memory usage question > > > >From: "Mark Hahn" >> >> I need to write a script that will use a hash with 4 million strings of 16 >> chars each. As a test I wrote this quick script: >> >> h = {}; s = 'aaaaaaaaaaaaaaaa' >> for i in 1..4_000_000 >> h[i] = (s = s.succ) >> end >> >> This ran relatively fast, but it consumed 265 megs of windows memory and >> failed with out of memory error at around 3 million elements. >> >> Why did Ruby fail at 265 megs and is there another way for me to do this? > >Interesting, I tried it under ruby 1.6.2 (2000-12-18) [i386-cygwin] >and got a failure at the same point (~265 megs), but instead of an >out-of-memory error, I got: > > /cygdrive/t/test.rb:5: [BUG] Segmentation fault > ruby 1.6.2 (2000-12-18) [i386-cygwin] > 0 [sig] ruby 1336 open_stackdumpfile: Dumping stack trace to > ruby.exe.stackdump > >Whereas under ruby 1.6.6 (2001-12-26) [i586-mswin32], the script >worked, allocating well over 300M, and completing successfully. > I tried it under ruby 1.6.4 on Linux and monitored it with top. The peak usage I saw was around 260MB and it took a little over 10 minutes to complete on my Duron 800. Phil