From: Alan Chen Date: 2002-01-16T03:54:16+09:00 Subject: [OT] Re: memory usage question On Wed, Jan 16, 2002 at 03:33:35AM +0900, Phil Tomson wrote: > In article <00d801c19def$cd7c3b20$5d091b18@austin.rr.com>, > Hal E. Fulton wrote: > >----- Original Message ----- > >From: "Mark Hahn" > >To: "ruby-talk ML" > >Sent: Tuesday, January 15, 2002 11:37 AM > >Subject: memory usage question > > > > > >> 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? > > > >Four million strings, eh? :) > > > > > >Buncha young kids wanna allocate data structures with four million > >items... in my day, we had 64K of RAM and part of that was the OS > >and the runtime. The compiler wouldn't all fit in memory at once. It > >was swapped out to this clunky external Shugart floppy disk drive > >that would walk across the table if you didn't tape it down. It made a > >noise like a boa constrictor gagging on a weasel. And the compiler > >couldn't handle arrays bigger than a thousand elements. > >And we LIKED IT... > > > > And in my day we had 16K of RAM and no Shugart floppy, we saved our > programs and data on casette tapes, believe it or not, and your program > loaded from tape at about 600 baud... But the worst part was that the > programs we wrote were in BASIC or machine code (not assembly, we're > talking typing in the Hex for he opcodes - we considered ourselves lucky > to not have to toggle our programs in with switches :). Of course we > walked several miles to school in the snow, too. Uphill both ways ;-) > > Phil > Ahhh, That brings back the senior project for my Aerospace Engineering degree. I was manually swapping out computer fluid dynamics grids and coeffecients to files as I completed calculations on them on my dos based x86 with 4MB. IIRC, the data for my entire grid was 800MB in total... I think running that for three or four days straight led to the premature death of my hard drive in that machine... -- alan -- Alan Chen Digikata LLC http://digikata.com