------art_155137_16870689.1156670520269
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 8/27/06, ako... <akonsu / gmail.com> wrote:
>
> thanks, i did not know that one can count objects using ObjectSpace.


No ObjectSpace counts them for you
ObjectSpace.each_object{}


it looks like map+join use fewer objects than inject. even though map
> creates a whole new array. i would expect inject to use fewer objects.
> strange...


No I do not think so, I believe that "+" uses the objects.
What good does it do disable GC and count objects afterwards?

This is very tricky to test, and I completely screwed up the first time.
Anway avoid "+" in inject use "<<" if memory is a concern.

I still think that maybe a simple each with some programming around is the
best approach
in our case
s
each |e| s << e
s

or

injcect "" |s,e| s << e

map/join is more elegant but if memory is a concern forget it.

konstantin
>
> <SNIP>

Cheers
Robert

------art_155137_16870689.1156670520269--