From: Masahiro TANAKA Date: 2005-09-08T12:55:51+09:00 Subject: Re: sharing memory in ruby Hi, >Ara wrote: > + ary->ref = Qfalse; > > the 'ary->ref' means it will not be free'd... This is not what I have intended. 'ary->ref' is an object that is referred from NArray object so that the original String object is not garbage-collected. So here should be `ary->ref = str;'. > + ary->ptr = RSTRING(str)->ptr; This has a serious caveat. s = "0000" na = NArray.str(s,2,NArray::SINT) s << "1"*100 # The memory of 's' will be reallocated. puts na[0] # accesses an invalid memory. However, I think it would be quite useful if Ruby have something like a common memory framework, which Ara suggested, for handling huge memory. Masahiro Tanaka