Ruby GC

I’ve been trying to look at how dynamic languages do memory management

  • mostly Ruby and Python - because I’ve been trying to implement a GC
    of my own.

The main problem that I’m interested in is how the GC deals with
segmentation. Python’s GC doesn’t do this, so that could solve it.

I’ve tried looking at Ruby’s source code, but I’ve found that its hard
to read and that I don’t understand what it’s GC is doing.

So, my question is, does Ruby’s GC (which is a mark-and-sweep
collector, I believe) deal with segmentation, and if it does, how?
Also, how does it deal with internal pointers to objects on the heap
if those objects are moved? (I mean, if theres a pointer to an object
in the heap, and the object is moved, how does Ruby locate it again?
Or does it avoid this situation by using some sort of lookup
mechanism?)

Perhaps these questions are a bit too low-level detailed, I’m not
sure.

Anyway, I’d be grateful if someone could clarify those things for me.
Thanks in advance!

– Pie Squared

Pie Squared wrote:

So, my question is, does Ruby’s GC (which is a mark-and-sweep
collector, I believe) deal with segmentation, and if it does, how?
Also, how does it deal with internal pointers to objects on the heap
if those objects are moved? (I mean, if theres a pointer to an object
in the heap, and the object is moved, how does Ruby locate it again?
Or does it avoid this situation by using some sort of lookup
mechanism?)

Ruby 1.8.6 and 1.9 do not have compacting collectors, so the memory
space gets increasingly more segmented.

JRuby is based on the JVM, which boasts some of the best GC
implementations in the world. Rubinius also has a simple generational
compacting M/S GC that avoids segmentation. As I understand it, memory
segmentation/fragmentation in Ruby 1.8.6 and Ruby 1.9 are a serious
problem for long-running applications.

  • Charlie

Charles Oliver N. wrote:

space gets increasingly more segmented.
The correct term is fragmentation. Segmentation is something quite
different, the division of main memory into memory subsystems/regions.

On Wed, Feb 27, 2008 at 7:11 AM, Christian Rubio
[email protected] wrote:

Are there any libraries in Ruby that allow me to plot multiple x and
y coordinates?

tioga, it’s trully great!

Marcelo

Eliot M. wrote:

Ruby 1.8.6 and 1.9 do not have compacting collectors, so the memory
space gets increasingly more segmented.

The correct term is fragmentation. Segmentation is something quite
different, the division of main memory into memory subsystems/regions.

Right you are. I used the OP’s term to avoid confusion there.

  • Charlie

Marcelo wrote:

Marcelo

Wow, I tried to install that and it requires pdflatex. Which comes on a
900mb TeX live cd and I cannot install that.

I just would like to be able to plot points. Is there anything like a
stdDraw or something

Christian Rubio wrote:

Marcelo

Wow, I tried to install that and it requires pdflatex. Which comes on a
900mb TeX live cd and I cannot install that.

I’ve drooled over the lovely images before, so yesterday I tried
installing all of pdflatex and its dependencies (via apt-get, not a cd).
Tioga still didn’t work (even after reinstalling and rebuilding it):

$ ruby ts_Tioga.rb
ruby: symbol lookup error:
/usr/local/lib/ruby/gems/1.8/gems/tioga-1.7/lib/Tioga/FigureMaker.so:
undefined symbol: Init_Font_Dictionary

Anybody have any ideas?

I just would like to be able to plot points. Is there anything like a
stdDraw or something

What about gnuplot or tkcanvas? The latter has the advantage of being
dynamic.

If you want to use JRuby, you can use JFreeChart.

Joe

On Wed, Feb 27, 2008 at 8:11 AM, Christian Rubio

you may also use google charts.

Hi all,

I am trying to plot some graphs.

Are there any libraries in Ruby that allow me to plot multiple x and y
coordinates?

Thanks

Ruby 1.8.6 and 1.9 do not have compacting collectors, so the memory
space gets increasingly more segmented.

For the record, MRI 1.9 sorts its ‘free’ objects in ascending order,
thus tending to “fill” memory slots that are close together. Since the
GC is fairly aggressive [it by default runs pretty frequently–a mixed
blessing] it therefore avoids some fragmentation.

There also was one report of a fellow who, on a long-running Ruby app,
experienced fragmentation due to the fact that by default ruby uses
malloc. Malloc itself causes some fragmentation so he switched his to
ptmalloc3 [1]. Ruby Enterprise Edition uses tcmalloc with probably
similar [possibly better] results.

-=R