New Object allocation
Free List
A
L
L
O
C
A
T
E
D
F
R
E
E
Slide 9
Slide 9 text
New Object allocation
Free List
A
L
L
O
C
A
T
E
D
Slide 10
Slide 10 text
New Object allocation
Free List is empty
A
L
L
O
C
A
T
E
D
Slide 11
Slide 11 text
New Object allocation
Free List is empty – Call GC
A
L
L
O
C
A
T
E
D
Slide 12
Slide 12 text
GC Process
●
GC finds non-reachable objects and adds
them to Free List
●
If Free List is still empty, another Heap
allocated
Slide 13
Slide 13 text
MRI GC
●
“Conservative”: any bit pattern could be a
pointer (may produce false positive)
●
“Stop the world”: no other Ruby code can
execute during GC
●
“Mark & Sweep”:
mark all objects in use, than sweep away
unmarked objects
Slide 14
Slide 14 text
More Objects => Longer GC => Slow
Slide 15
Slide 15 text
In our case – Out of Memory!
Slide 16
Slide 16 text
How to Debug?
●
gem "pry-debugger"
https://github.com/nixme/pry-debugger
●
gem "debugger-pry"
https://github.com/pry/debugger-pry
Slide 17
Slide 17 text
Tools
●
ObjectSpace.count_objects
●
GC debug - Enable heap dump support
●
gdb.rb (only Linux)
Note: memprof works only with Ruby 1.8
Slide 18
Slide 18 text
ObjectSpace.count_objects
Slide 19
Slide 19 text
Enable heap dump support to Ruby
Install custom patched version of ruby
Usage:
Slide 20
Slide 20 text
https://github.com/tmm1/gdb.rb
Attached to existing process and
examine the HEAP