From: Carter Cheng Date: 2011-10-20T10:23:23+09:00 Subject: [ruby-core:40239] Re: invoking garbage_collect in gc.c --f46d043bdfb85d256d04afb0cd68 Content-Type: text/plain; charset=ISO-8859-1 Thanks Nari. On Thu, Oct 20, 2011 at 11:52 AM, Narihiro Nakamura 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) > > --f46d043bdfb85d256d04afb0cd68 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks Nari.

On Thu, Oct 20, 2011 at 11:5= 2 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 S= weep 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://ru= byconf11.merbist.com/#57

Thanks.
--
Narihiro Nakamura (nari)


--f46d043bdfb85d256d04afb0cd68--