From: William Djaja Tjokroaminata Date: 2002-08-29T22:52:49+09:00 Subject: Re: Temporary VALUE Needs to Be Protected? Hi, Thanks for the thought; it is comforting. Yes, initially when I started to learn how to write Ruby in C, I did simple translation (which means converting "@data" to "rb_iv_get (obj, "@data")"). As I learned more, most of the data has been converted to C struct members. Actually I went too far, with the result, probably it is hard to believe at first, that the Ruby code will look like... Python (the language from which I switched to Ruby) :) . I guess we really cannot gain something for nothing... Yes, I have minimized the marking functions only to the absolute necessities. The only problem is, even when I control the GC manually (switch it off temporarily), when it is time to invoke GC, the resource taken by GC in the marking phase is really proportional to the number of objects, whereas in fact most of the objects live until the end of the process. This makes my application not scale well, something that is not true when we code in C or C++. On the other hand, if I write my application in pure C++ (I have tried it before, and it just took too long), I will miss all the wonderful things that Ruby provides... Oh well, I guess life is full of hard choices... Regards, Bill ============================================================================ Christian Szegedy wrote: > I don't have not made any tests but my intuition says that under normal > circumstances, the size of the (used part of) stack must be fairly > negligible compared to the heap, therefore, it should not make > significant overhead. > I think, mixing C-style allocations and Ruby style Objects is fairly > trivial in Ruby. If your C-structure does not reference any Ruby > object, then you don't need to mark anything. OTOHS, you have to mark > every referenced Ruby object. Under normal circumstances, it should > not be too hard... > Of course, Rubys GC is far from optimal, but it is still quite OK for > most applications. Besides this, you can switch it off (temporarily), > or trigger GC if you think it is appropriate in certain situations. > Regards, Christian