From: Matt Armstrong Date: 2002-01-16T04:14:51+09:00 Subject: Re: memory usage question Phil Tomson writes: > On Tue, 15 Jan 2002, Matt Armstrong wrote: > >> ptkwt@shell1.aracnet.com (Phil Tomson) writes: >> >> > In article , >> > Mark Hahn wrote: >> >> >> >>> you should consider using a database >> >> >> >>Doing 200 million lookups in a db would take way too long for my >> >>script. If there is no other work-around than using a DB, then I'll >> >>have to go back to Java, which can handle this kind of memory usage. >> >>I'm dissapointed that in one of the first quick scripts I went to >> >>Ruby for, Ruby couldn't do the job. >> > >> > How does java acheive this feat? >> > (or how do you do it in java?) >> >> 4 million 16 character strings is only 64 megs. > > They're not wide characters in java? > > So you're saying that Ruby strings take up more space? (probably, > since doesn't ruby use wide chars?) > > What do these 16 character strings represent? You're right, think Java does us 16 bit Unicode chars. Ruby doesn't. It uses UTF-8 or SJIS, etc. These all use one byte for an ASCII character and multiple byte encodings for others. >> Even if the overhead of a String object itself and the entry in the >> hash table is 4 times that, you're still only at about 300 megs. >> On a machine with 4 gigs of RAM, that should be possible. > > Yes, but I think that's a lot more available RAM than you mentioned > in your original post. From what you said earlier if you 4gigs of > RAM then the Ruby version should work without any problem (am I > missing something?) Exactly, but the original poster says it doesn't work -- that is the whole question. -- matt