Ruby GC

P

Pie Squared

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
 
C

Charles Oliver Nutter

Pie said:
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
 
E

Eliot Miranda

Charles said:
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.
 
C

Charles Oliver Nutter

Eliot said:
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
 
J

Joel VanderWerf

Christian said:
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.
 
P

Piyush Ranjan

[Note: parts of this message were removed to make it a legal post.]

you may also use google charts.
 
R

Roger Pack

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,829
Latest member
KimberAlli

Latest Threads

Top