I do not see the position from which gc_sweep or gc_lazy_sweep is called in
the code(I did a preliminary search using grep). I would appreciate it if
you could point me to the location where the gc is triggered according to
the condition you just mentioned.

On Thu, Oct 20, 2011 at 12:23 PM, Carter Cheng <cartercheng / gmail.com>wrote:

> Thanks Nari.
>
> On Thu, Oct 20, 2011 at 11:52 AM, Narihiro Nakamura <authornari / gmail.com>wrote:
>
>> Hi,
>>
>> > Hello,
>> >
>> > I hope people do not mind that I have a followup question-
>> >
>> > from where is the garbage collector invoked in the interpreter?
>>
>> Let me talk about trunk's GC because CRuby's GC adopts Lasy Sweep GC
>> since Ruby 1.9.3.
>>
>> In many case, GC is invoked at following cases.
>>
>> 1. When the interpreter allocate some Ruby's object.
>> 2. When you call GC.start in your Ruby programs.
>> 3. When malloc_increase exceeds malloc_limit.
>>
>> In 2. and 3. cases, GC executs mark and sweep atomically by using
>> garbage_collect() in gc.c.
>>
>> In 1. and Ruby's heap don't have a unswept object cases, GC executs
>> mark and sweep that sweeps Ruby's heap until it finds an appropriate
>> free object.
>>
>> In 1. and Ruby's heap has a unswept object cases, GC executs sweep
>> until it finds an appropriate free object.
>>
>> Please see gc_lazy_sweep() in gc.c if you want to know a detail of
>> this process.
>>
>> # And, you can see matt's great presentation for this topic.
>> # http://rubyconf11.merbist.com/#57
>>
>> Thanks.
>> --
>> Narihiro Nakamura (nari)
>>
>>
>